Skip to content

Commit

Permalink
Merge pull request #634 from stefopl/okapi-633
Browse files Browse the repository at this point in the history
fix(#633): handle invalid UUIDs in found_by parameter
  • Loading branch information
deg-pl authored Dec 10, 2024
2 parents 4e4db56 + 8f8c880 commit 3aab571
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions okapi/services/caches/search/SearchAssistant.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,23 @@ public function prepare_common_search_params()
throw new InvalidParam('found_by', $e->whats_wrong_about_it);
}

if (empty($users) || !is_array($users)) {
throw new InvalidParam('found_by', "No valid users found for the given parameter.");
}

$user_uuids = explode("|", $tmp);

$invalid_uuids = [];
foreach ($user_uuids as $uuid) {
if (!isset($users[$uuid])) {
$invalid_uuids[] = $uuid;
}
}

if (!empty($invalid_uuids)) {
throw new InvalidParam('found_by', "The following UUID(s) are invalid or not found: " . implode(", ", $invalid_uuids));
}

$internal_user_ids = array_map(function ($user) { return $user["internal_id"]; }, $users);
if (Settings::get('USE_SQL_SUBQUERIES')) {
$found_cache_subquery = self::get_found_cache_ids_subquery($internal_user_ids);
Expand Down

0 comments on commit 3aab571

Please sign in to comment.