PluginProbe
User Access Manager / 2.3.17
User Access Manager v2.3.17
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
← All changes | src/UserGroup/AssignedObjectsLoader.php +12 -8 trunk2.3.17 View file →
@@ -27,9 +27,11 @@
27 27 int|string|null $userGroupId,
28 28 string $objectType,
29 29 bool $ignoreDates
30 30 ): array {
31 - $this->assignedObjects[$objectType][$ignoreDates] ??= $this->loadAssignedObjects($objectType, $ignoreDates);
31 + if (isset($this->assignedObjects[$objectType][$ignoreDates]) === false) {
32 + $this->assignedObjects[$objectType][$ignoreDates] = $this->loadAssignedObjects($objectType, $ignoreDates);
33 + }
32 34
33 35 return $this->assignedObjects[$objectType][$ignoreDates][$userGroupType][$userGroupId] ?? [];
34 36 }
35 37
@@ -42,13 +44,13 @@
42 44 * @return array<string, array<string, AssignmentInformation[]>>
43 45 */
44 46 private function loadAssignedObjects(string $objectType, bool $ignoreDates): array
45 47 {
46 - $query = "SELECT `group_id` AS `groupId`, `group_type` AS `groupType`, `object_id` AS `id`,
47 - `object_type` AS `objectType`, `from_date` AS `fromDate`, `to_date` AS `toDate`
48 - FROM `{$this->database->getUserGroupToObjectTable()}`
49 - WHERE `object_id` != ''
50 - AND (`general_object_type` = '%s' OR `object_type` = '%s')";
48 + $query = "SELECT group_id AS groupId, group_type AS groupType, object_id AS id,
49 + object_type AS objectType, from_date AS fromDate, to_date AS toDate
50 + FROM {$this->database->getUserGroupToObjectTable()}
51 + WHERE object_id != ''
52 + AND (general_object_type = '%s' OR object_type = '%s')";
51 53
52 54 $parameters = [
53 55 $objectType,
54 56 $objectType
@@ -54,16 +56,18 @@
54 56 $objectType
55 57 ];
56 58
57 59 if ($ignoreDates === false) {
58 - $query .= " AND (`from_date` IS NULL OR `from_date` <= '%s') AND (`to_date` IS NULL OR `to_date` >= '%s')";
60 + $query .= " AND (from_date IS NULL OR from_date <= '%s') AND (to_date IS NULL OR to_date >= '%s')";
59 61 $time = $this->wordpress->currentTime('mysql');
60 62 $parameters = array_merge($parameters, [$time, $time]);
61 63 }
62 64
65 + $query = $this->database->prepare($query, $parameters);
66 + $results = (array) $this->database->getResults($query);
63 67 $assignedObjects = [];
64 68
65 - foreach ((array) $this->database->getResults($this->database->prepare($query, $parameters)) as $result) {
69 + foreach ($results as $result) {
66 70 $assignedObjects[$result->groupType][$result->groupId][$result->id] = $this->assignmentInformationFactory
67 71 ->createAssignmentInformation($result->objectType, $result->fromDate, $result->toDate);
68 72 }
69 73