Skip to content

Commit

Permalink
[jan] Fix sorting by due date with PHP < 5.5 (Bug #14507).
Browse files Browse the repository at this point in the history
Fixes regression introduced with fix for bug 14504.
  • Loading branch information
yunosh committed Nov 9, 2016
1 parent 4f39ede commit 00ec780
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions nag/docs/CHANGES
Expand Up @@ -2,6 +2,7 @@
v4.2.13-git
-----------

[jan] Fix sorting by due date with PHP < 5.5 (Bug #14507).


-------
Expand Down
22 changes: 11 additions & 11 deletions nag/lib/Nag.php
Expand Up @@ -1535,26 +1535,26 @@ static public function _rsortByEstimate($a, $b)
*/
static public function _sortByDue($a, $b)
{
$a_due = empty($a->getNextDue())
? 0
: $a->getNextDue()->timestamp();
$b_due = empty($b->getNextDue())
? 0
: $b->getNextDue()->timestamp();

if ($a_due == $b_due) {
$a_due = $a->getNextDue();
$b_due = $b->getNextDue();

if (!$a_due && !$b_due) {
return self::_sortByName($a, $b);
}

// Treat empty due dates as farthest into the future.
if ($a_due == 0) {
if (!$a_due) {
return 1;
}
if ($b_due == 0) {
if (!$b_due) {
return -1;
}

return ($a_due > $b_due) ? 1 : -1;
if ($a_due->equals($b_due)) {
return self::_sortByName($a, $b);
}

return ($a_due->after($b_due)) ? 1 : -1;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions nag/package.xml
Expand Up @@ -33,7 +33,7 @@
</stability>
<license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
<notes>
*
* [jan] Fix sorting by due date with PHP &lt; 5.5 (Bug #14507).
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -1766,7 +1766,7 @@
<date>2016-11-08</date>
<license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
<notes>
*
* [jan] Fix sorting by due date with PHP &lt; 5.5 (Bug #14507).
</notes>
</release>
</changelog>
Expand Down

0 comments on commit 00ec780

Please sign in to comment.