Skip to content

Commit

Permalink
bugs.webkit.org internal server error when limiting search by 1 month
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=257546
rdar://110075621

Reviewed by Alexey Proskuryakov.

Fixed SqlifyDate function in Bugzilla/Search.pm such that it multiplies month by 31 days and returns valid date.
Previously it would change only the month and keep the day of the month the same, causing invalid dates to be
returned depending on certain dates and how far to go back to.

* Websites/bugs.webkit.org/Bugzilla/Search.pm:
(SqlifyDate):

Canonical link: https://commits.webkit.org/264820@main
  • Loading branch information
lingcherd committed Jun 2, 2023
1 parent 0556ac6 commit 48759de
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions Websites/bugs.webkit.org/Bugzilla/Search.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2217,7 +2217,20 @@ sub SqlifyDate {
my ($sec, $min, $hour, $mday, $month, $year, $wday) = localtime($date);
if ($sign && $sign eq '+') { $amount = -$amount; }
$startof = 1 if $amount == 0;
if ($unit eq 'w') { # convert weeks to days
# WEBKIT_CHANGES: Fixed invalid date returns on some occasions.
if ($unit eq 'm') {
$month -= $amount;
$year += floor($month/12);
$month %= 12;
if ($startof) {
return sprintf("%4d-%02d-01 00:00:00", $year+1900, $month+1);
}
else {
$amount = 31*$amount;
$unit = 'd';
}
}
elsif ($unit eq 'w') { # convert weeks to days
$amount = 7*$amount;
$amount += $wday if $startof;
$unit = 'd';
Expand All @@ -2239,18 +2252,6 @@ sub SqlifyDate {
$year+1900-$amount, $month+1, $mday, $hour, $min, $sec);
}
}
elsif ($unit eq 'm') {
$month -= $amount;
$year += floor($month/12);
$month %= 12;
if ($startof) {
return sprintf("%4d-%02d-01 00:00:00", $year+1900, $month+1);
}
else {
return sprintf("%4d-%02d-%02d %02d:%02d:%02d",
$year+1900, $month+1, $mday, $hour, $min, $sec);
}
}
elsif ($unit eq 'h') {
# Special case for 'beginning of an hour'
if ($startof) {
Expand Down

0 comments on commit 48759de

Please sign in to comment.