Skip to content

Commit 3aab571

Browse files
authored
Merge pull request #634 from stefopl/okapi-633
fix(#633): handle invalid UUIDs in found_by parameter
2 parents 4e4db56 + 8f8c880 commit 3aab571

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

okapi/services/caches/search/SearchAssistant.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,23 @@ public function prepare_common_search_params()
427427
throw new InvalidParam('found_by', $e->whats_wrong_about_it);
428428
}
429429

430+
if (empty($users) || !is_array($users)) {
431+
throw new InvalidParam('found_by', "No valid users found for the given parameter.");
432+
}
433+
434+
$user_uuids = explode("|", $tmp);
435+
436+
$invalid_uuids = [];
437+
foreach ($user_uuids as $uuid) {
438+
if (!isset($users[$uuid])) {
439+
$invalid_uuids[] = $uuid;
440+
}
441+
}
442+
443+
if (!empty($invalid_uuids)) {
444+
throw new InvalidParam('found_by', "The following UUID(s) are invalid or not found: " . implode(", ", $invalid_uuids));
445+
}
446+
430447
$internal_user_ids = array_map(function ($user) { return $user["internal_id"]; }, $users);
431448
if (Settings::get('USE_SQL_SUBQUERIES')) {
432449
$found_cache_subquery = self::get_found_cache_ids_subquery($internal_user_ids);

0 commit comments

Comments
 (0)