Only touch orders property if we're going to add to it

This commit is contained in:
Toby Zerner 2017-11-13 13:18:36 +10:30
parent c7d7b2d360
commit 20f6a256d5

View File

@ -45,16 +45,16 @@ class PinStickiedDiscussionsToTop
$search = $event->search;
$query = $search->getQuery();
if (! is_array($query->orders)) {
$query->orders = [];
}
// If we are viewing a specific tag, then pin all stickied
// discussions to the top no matter what.
$gambits = $search->getActiveGambits();
foreach ($gambits as $gambit) {
if ($gambit instanceof TagGambit) {
if (! is_array($query->orders)) {
$query->orders = [];
}
array_unshift($query->orders, ['column' => 'is_sticky', 'direction' => 'desc']);
return;