chg: [internal] Use SORT_REGULAR for array_unique

pull/8358/head
Jakub Onderka 2022-05-18 10:06:17 +02:00
parent 715ca6d1e2
commit 2f644a2a33
4 changed files with 33 additions and 3 deletions

View File

@ -619,7 +619,7 @@ class EventsController extends AppController
if (empty($usersToMatch)) {
$nothing = true;
} else {
$this->paginate['conditions']['AND'][] = ['Event.user_id' => array_unique($usersToMatch)];
$this->paginate['conditions']['AND'][] = ['Event.user_id' => array_unique($usersToMatch, SORT_REGULAR)];
}
}
break;

View File

@ -30,4 +30,34 @@ class BetterCakeEventManager extends CakeEventManager
}
}
}
/**
* @param $eventKey
* @return array
*/
public function listeners($eventKey)
{
if ($this->_isGlobal) {
$localListeners = [];
} else {
$localListeners = $this->_listeners[$eventKey] ?? [];
}
$globalListeners = static::instance()->prioritisedListeners($eventKey);
$priorities = array_merge(array_keys($globalListeners), array_keys($localListeners));
$priorities = array_unique($priorities, SORT_REGULAR);
asort($priorities);
$result = [];
foreach ($priorities as $priority) {
if (isset($globalListeners[$priority])) {
$result = array_merge($result, $globalListeners[$priority]);
}
if (isset($localListeners[$priority])) {
$result = array_merge($result, $localListeners[$priority]);
}
}
return $result;
}
}

View File

@ -769,7 +769,7 @@ class Event extends AppModel
}
$correlations = array_column($correlations, $correlationModelName);
$eventIds = array_unique(array_column($correlations, 'event_id'));
$eventIds = array_unique(array_column($correlations, 'event_id'), SORT_REGULAR);
$conditions = $this->createEventConditions($user);
$conditions['Event.id'] = $eventIds;

View File

@ -1124,7 +1124,7 @@ class GalaxyCluster extends AppModel
if (!empty($tagsToFetch)) {
$tags = $this->GalaxyClusterRelation->GalaxyClusterRelationTag->Tag->find('all', [
'conditions' => ['id' => array_unique($tagsToFetch)],
'conditions' => ['id' => array_unique($tagsToFetch, SORT_REGULAR)],
'recursive' => -1,
]);
$tags = array_column(array_column($tags, 'Tag'), null, 'id');