mirror of
https://github.com/WhatCD/Gazelle.git
synced 2025-01-18 12:11:36 +00:00
Prevent the merging of non-music groups
Include empty values in cache debug table Clear cache when replying to staff pm Internal cache is useless in get_artists and get_groups Prevent users from clearing certain cache keys
This commit is contained in:
parent
fb4810d625
commit
1ae6832107
@ -34,6 +34,10 @@ class CACHE extends Memcache {
|
||||
public $MemcacheDBKey = '';
|
||||
protected $InTransaction = false;
|
||||
public $Time = 0;
|
||||
private $PersistentKeys = array(
|
||||
'stats_*',
|
||||
'percentiles_*',
|
||||
);
|
||||
|
||||
public $CanClear = false;
|
||||
|
||||
@ -77,14 +81,16 @@ public function get_value($Key, $NoCache=false) {
|
||||
trigger_error("Cache retrieval failed for empty key");
|
||||
}
|
||||
|
||||
if (isset($_GET['clearcache']) && $this->CanClear) {
|
||||
if (isset($_GET['clearcache']) && $this->CanClear && !in_array_partial($Key, $this->PersistentKeys)) {
|
||||
if ($_GET['clearcache'] == 1) {
|
||||
//Because check_perms isn't true until loggeduser is pulled from the cache, we have to remove the entries loaded before the loggeduser data
|
||||
//Because of this, not user cache data will require a secondary pageload following the clearcache to update
|
||||
if (count($this->CacheHits) > 0) {
|
||||
foreach ($this->CacheHits as $Key => $Entry) {
|
||||
$this->delete($Key);
|
||||
unset($this->CacheHits[$Key]);
|
||||
foreach (array_keys($this->CacheHits) as $HitKey) {
|
||||
if (!in_array_partial($HitKey, $this->PersistentKeys)) {
|
||||
$this->delete($HitKey);
|
||||
unset($this->CacheHits[$HitKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->delete($Key);
|
||||
|
@ -1901,6 +1901,31 @@ function starts_with($Haystack, $Needle) {
|
||||
return strpos($Haystack, $Needle) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Variant of in_array() with trailing wildcard support
|
||||
* @param string $Needle, array $Haystack
|
||||
* @return true if (substring of) $Needle exists in $Haystack
|
||||
*/
|
||||
function in_array_partial($Needle, $Haystack) {
|
||||
static $Searches = array();
|
||||
if(array_key_exists($Needle, $Searches)) {
|
||||
return $Searches[$Needle];
|
||||
}
|
||||
foreach($Haystack as $String) {
|
||||
if(substr($String, -1) == '*') {
|
||||
if(!strncmp($Needle, $String, strlen($String)-1)) {
|
||||
$Searches[$Needle] = true;
|
||||
return true;
|
||||
}
|
||||
} elseif(!strcmp($Needle, $String)) {
|
||||
$Searches[$Needle] = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$Searches[$Needle] = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$Debug->set_flag('ending function definitions');
|
||||
|
Loading…
Reference in New Issue
Block a user