# UNDF: UNDF-2026-000000867 --- a/htdocs/datapolicy/class/datapolicycron.class.php +++ b/htdocs/datapolicy/class/datapolicycron.class.php @@ -335,6 +335,7 @@ * @param int[] $processedIds Reference to the array of processed IDs. * @param object $conf The global conf object. * @param User $user The user object for history tracking. + * Note: $processedIds is used as both array and set; callers should also pass $processedSet for O(1) lookup. * @return void */ private function _processPolicyAction($policy, $action, $object, &$processedIds, $conf, $user) @@ -367,7 +368,8 @@ // Process the records found by the query + $processedSet = array_flip($processedIds); // O(1) lookup instead of O(N) in_array while ($obj = $this->db->fetch_object($resql)) { - if (in_array($obj->rowid, $processedIds) || ! method_exists($this, $handlerMethod)) { + if (isset($processedSet[$obj->rowid]) || ! method_exists($this, $handlerMethod)) { continue; } /** @var CommonObject $object */ @@ -383,6 +385,7 @@ // Record the outcome and add to processed list on success $this->_recordActionResult($result, $object, $action); $processedIds[] = $obj->rowid; + $processedSet[$obj->rowid] = true; } }