Skip to content

Commit

Permalink
Force cached search builder list values to objects to ensure they are…
Browse files Browse the repository at this point in the history
… encoded in JSON as objects and don't lose their keys
  • Loading branch information
collectiveaccess committed Oct 18, 2024
1 parent 47ab118 commit fcfdafd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/helpers/searchHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2108,7 +2108,16 @@ function caGetSearchBuilderFilters(BaseModel $t_subject, Configuration $search_b
$show_container_in_labels = caGetOption('showContainerInLabel', $options, false);

$key = 'filters_'.$t_subject->tableName().caMakeCacheKeyFromOptions($options ?? [], $t_user ? $t_user->getUserID() : '');
if (!caGetOption('noCache', $options, false) && CompositeCache::contains($key, 'SearchBuilder') && is_array($cached_data = CompositeCache::fetch($key, 'SearchBuilder'))) { return $cached_data; }
if (!caGetOption('noCache', $options, false) && CompositeCache::contains($key, 'SearchBuilder') && is_array($cached_data = CompositeCache::fetch($key, 'SearchBuilder'))) {
// Values come out of the cache as arrays, but QueryBuilder wants them to be objects in the encoded JSON
// so we cast them to objects here
foreach($cached_data as $k => $v) {
if(isset($v['values']) && is_array($v['values'])) {
$cached_data[$k]['values'] = (object)$cached_data[$k]['values'];
}
}
return $cached_data;
}

$table = $t_subject->tableName();
$t_search_form = new ca_search_forms();
Expand Down

0 comments on commit fcfdafd

Please sign in to comment.