From a8e210faa624517ee8b8978b7e659a0b3c689297 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 29 Aug 2020 10:06:40 +0200 Subject: Fixed: Pinned bookmarks are displayed first in ATOM/RSS feeds Fixes #1485 --- application/bookmark/BookmarkArray.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'application/bookmark/BookmarkArray.php') diff --git a/application/bookmark/BookmarkArray.php b/application/bookmark/BookmarkArray.php index d87d43b4..3bd5eb20 100644 --- a/application/bookmark/BookmarkArray.php +++ b/application/bookmark/BookmarkArray.php @@ -234,16 +234,17 @@ class BookmarkArray implements \Iterator, \Countable, \ArrayAccess * * Also update the urls and ids mapping arrays. * - * @param string $order ASC|DESC + * @param string $order ASC|DESC + * @param bool $ignoreSticky If set to true, sticky bookmarks won't be first */ - public function reorder($order = 'DESC') + public function reorder(string $order = 'DESC', bool $ignoreSticky = false): void { $order = $order === 'ASC' ? -1 : 1; // Reorder array by dates. - usort($this->bookmarks, function ($a, $b) use ($order) { + usort($this->bookmarks, function ($a, $b) use ($order, $ignoreSticky) { /** @var $a Bookmark */ /** @var $b Bookmark */ - if ($a->isSticky() !== $b->isSticky()) { + if (false === $ignoreSticky && $a->isSticky() !== $b->isSticky()) { return $a->isSticky() ? -1 : 1; } return $a->getCreated() < $b->getCreated() ? 1 * $order : -1 * $order; -- cgit v1.2.3