safer cache keys

This commit is contained in:
Shish 2023-02-14 01:19:28 +00:00
parent ede2dc7cfe
commit ae8d8033b9
2 changed files with 4 additions and 4 deletions

View file

@ -51,7 +51,7 @@ class AutoComplete extends Extension
}
# memcache keys can't contain spaces
$cache_key = str_replace(' ', '+', "autocomplete-$search");
$cache_key = "autocomplete:" . md5($search);
$limitSQL = "";
$search = str_replace('_', '\_', $search);
$search = str_replace('%', '\%', $search);

View file

@ -555,8 +555,8 @@ class TagList extends Extension
$wild_tags = $search;
$str_search = str_replace(" ", "+", Tag::implode($search));
$related_tags = $cache->get("related_tags:$str_search");
$cache_key = "related_tags:" . md5(Tag::implode($search));
$related_tags = $cache->get($cache_key);
if (is_null($related_tags)) {
// $search_tags = array();
@ -610,7 +610,7 @@ class TagList extends Extension
} else {
$related_tags = [];
}
$cache->set("related_tags:$str_search", $related_tags, 60 * 60);
$cache->set($cache_key, $related_tags, 60 * 60);
}
return $related_tags;
}