1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 05:37:32 +02:00

Should help with Issue #53 - PHP Strict issues

This commit is contained in:
Cameron
2012-12-15 03:49:15 -08:00
parent b74bf451d7
commit 71cd2aca3c
5 changed files with 29 additions and 19 deletions

View File

@@ -1445,7 +1445,7 @@ function save_prefs($table = 'core', $uid = USERID, $row_val = '')
// Create the data to be stored // Create the data to be stored
if($sql->db_Select_gen("REPLACE INTO `#core` (e107_name,e107_value) values ('SitePrefs', '".$eArrayStorage->WriteArray($_pref)."') ")) if($sql->db_Select_gen("REPLACE INTO `#core` (e107_name,e107_value) values ('SitePrefs', '".$eArrayStorage->WriteArray($_pref)."') "))
{ {
ecache::clear_sys('Config_core'); ecacXXXhe::clear_sys('Config_core');
return true; return true;
} }
else else

View File

@@ -36,8 +36,8 @@ class ecache {
function __construct() function __construct()
{ {
$this->UserCacheActive = e107::getPref('cachestatus'); //$this->UserCacheActive = e107::getPref('cachestatus');
$this->SystemCacheActive = e107::getPref('syscachestatus'); //$this->SystemCacheActive = e107::getPref('syscachestatus');
} }
/** /**
@@ -105,7 +105,7 @@ class ecache {
{ {
if(($ForcedCheck != false ) || ($syscache == false && $this->UserCacheActive) || ($syscache == true && $this->SystemCacheActive) && !e107::getParser()->checkHighlighting()) if(($ForcedCheck != false ) || ($syscache == false && $this->UserCacheActive) || ($syscache == true && $this->SystemCacheActive) && !e107::getParser()->checkHighlighting())
{ {
$cache_file = (isset($this) && $this instanceof ecache ? $this->cache_fname($CacheTag, $syscache) : ecache::cache_fname($CacheTag, $syscache)); $cache_file = (isset($this) && $this instanceof ecache ? $this->cache_fname($CacheTag, $syscache) : self::cache_fname($CacheTag, $syscache));
if (file_exists($cache_file)) if (file_exists($cache_file))
{ {
if ($MaximumAge != false && (filemtime($cache_file) + ($MaximumAge * 60)) < time()) { if ($MaximumAge != false && (filemtime($cache_file) + ($MaximumAge * 60)) < time()) {
@@ -133,9 +133,10 @@ class ecache {
} }
/** /**
* @return string * @return string
* @param string $query * @param string $CacheTag
* @param int $MaximumAge the time in minutes before the cache file 'expires' * @param int $MaximumAge the time in minutes before the cache file 'expires'
* @param boolean $force
* @desc Returns the data from the cache file associated with $query, else it returns false if there is no cache for $query. * @desc Returns the data from the cache file associated with $query, else it returns false if there is no cache for $query.
* @scope public * @scope public
*/ */
@@ -147,7 +148,7 @@ class ecache {
} }
else else
{ {
return ecache::retrieve($CacheTag, $MaximumAge, $ForcedCheck, true); return self::retrieve($CacheTag, $MaximumAge, $ForcedCheck, true);
} }
} }
@@ -165,7 +166,7 @@ class ecache {
{ {
if(($ForceCache != false ) || ($syscache == false && $this->UserCacheActive) || ($syscache == true && $this->SystemCacheActive) && !e107::getParser()->checkHighlighting()) if(($ForceCache != false ) || ($syscache == false && $this->UserCacheActive) || ($syscache == true && $this->SystemCacheActive) && !e107::getParser()->checkHighlighting())
{ {
$cache_file = (isset($this) && $this instanceof ecache ? $this->cache_fname($CacheTag, $syscache) : ecache::cache_fname($CacheTag, $syscache)); $cache_file = (isset($this) && $this instanceof ecache ? $this->cache_fname($CacheTag, $syscache) : self::cache_fname($CacheTag, $syscache));
@file_put_contents($cache_file, ($bRaw? $Data : self::CACHE_PREFIX.$Data) ); @file_put_contents($cache_file, ($bRaw? $Data : self::CACHE_PREFIX.$Data) );
@chmod($cache_file, 0755); //Cache should not be world-writeable @chmod($cache_file, 0755); //Cache should not be world-writeable
@touch($cache_file); @touch($cache_file);
@@ -189,7 +190,7 @@ class ecache {
} }
else else
{ {
ecache::set($CacheTag, $Data, $ForceCache, $bRaw, true); self::set($CacheTag, $Data, $ForceCache, $bRaw, true);
} }
} }
@@ -207,12 +208,14 @@ class ecache {
{ {
$file = ($CacheTag) ? preg_replace("#\W#", "_", $CacheTag)."*.cache.php" : "*.cache.php"; $file = ($CacheTag) ? preg_replace("#\W#", "_", $CacheTag)."*.cache.php" : "*.cache.php";
e107::getEvent()->triggerAdminEvent('cache_clear', "cachetag=$CacheTag&file=$file&syscache=$syscache"); e107::getEvent()->triggerAdminEvent('cache_clear', "cachetag=$CacheTag&file=$file&syscache=$syscache");
$ret = ecache::delete(e_CACHE_CONTENT, $file, $syscache); $ret = self::delete(e_CACHE_CONTENT, $file, $syscache);
if($CacheTag && $related) //TODO - too dirty - add it to the $file pattern above if($CacheTag && $related) //TODO - too dirty - add it to the $file pattern above
{ {
ecache::delete(e_CACHE_CONTENT, 'nq_'.$file, $syscache); self::delete(e_CACHE_CONTENT, 'nq_'.$file, $syscache);
ecache::delete(e_CACHE_CONTENT, 'nomd5_'.$file, $syscache); self::delete(e_CACHE_CONTENT, 'nomd5_'.$file, $syscache);
//ecache::delete(e_CACHE_CONTENT, 'nq_'.$file, $syscache);
//ecache::delete(e_CACHE_CONTENT, 'nomd5_'.$file, $syscache);
} }
return $ret; return $ret;
} }
@@ -230,7 +233,8 @@ class ecache {
} }
else else
{ {
ecache::clear($CacheTag, true, $related); self::clear($CacheTag, true, $related);
// ecache::clear($CacheTag, true, $related);
} }
} }

View File

@@ -832,6 +832,12 @@ class e107
{ {
e107_require_once(e_HANDLER.'pref_class.php'); e107_require_once(e_HANDLER.'pref_class.php');
self::$_core_config_arr[$name] = new e_core_pref($name, $load); self::$_core_config_arr[$name] = new e_core_pref($name, $load);
if($name == 'core') // prevent loop between pref and cache handlers.
{
e107::getCache()->UserCacheActive = self::getPref('cachestatus');
e107::getCache()->SystemCacheActive = self::getPref('syscachestatus');
}
} }
return self::$_core_config_arr[$name]; return self::$_core_config_arr[$name];

View File

@@ -491,7 +491,7 @@ class e_pref extends e_front_model
* *
* @param boolean $from_post merge post data * @param boolean $from_post merge post data
* @param boolean $force * @param boolean $force
* @param boolean $session_messages use session messages //FIXME Appears to be ignored on "Settings successfully saved."; * @param boolean $session_messages use session messages //FIXME Appears to be ignored on "Settings successfully saved.
* @return boolean|integer 0 - no change, true - saved, false - error * @return boolean|integer 0 - no change, true - saved, false - error
*/ */
public function save($from_post = true, $force = false, $session_messages = false) public function save($from_post = true, $force = false, $session_messages = false)
@@ -559,7 +559,7 @@ class e_pref extends e_front_model
if(e107::getDb()->db_Select_gen("REPLACE INTO `#core` (e107_name,e107_value) values ('".$this->prefid."_Backup', '".addslashes($dbdata)."') ")) if(e107::getDb()->db_Select_gen("REPLACE INTO `#core` (e107_name,e107_value) values ('".$this->prefid."_Backup', '".addslashes($dbdata)."') "))
{ {
if(!$disallow_logs) $admin_log->logMessage('Backup of <strong>'.$this->alias.' ('.$this->prefid.')</strong> successfully created.', E_MESSAGE_DEBUG, E_MESSAGE_SUCCESS, $session_messages); if(!$disallow_logs) $admin_log->logMessage('Backup of <strong>'.$this->alias.' ('.$this->prefid.')</strong> successfully created.', E_MESSAGE_DEBUG, E_MESSAGE_SUCCESS, $session_messages);
ecache::clear_sys('Config_'.$this->alias.'_backup'); e107::getCache()->clear_sys('Config_'.$this->alias.'_backup');
} }
} }
$this->setPrefCache($this->toString(false), true); //reset pref cache - runtime & file $this->setPrefCache($this->toString(false), true); //reset pref cache - runtime & file
@@ -609,7 +609,7 @@ class e_pref extends e_front_model
{ {
if(!$this->pref_cache) if(!$this->pref_cache)
{ {
$this->pref_cache = ecache::retrieve_sys('Config_'.$this->alias, 24 * 60, true); $this->pref_cache = e107::getCache()->retrieve_sys('Config_'.$this->alias, 24 * 60, true);
} }
return ($toArray && $this->pref_cache ? e107::getArrayStorage()->ReadArray($this->pref_cache) : $this->pref_cache); return ($toArray && $this->pref_cache ? e107::getArrayStorage()->ReadArray($this->pref_cache) : $this->pref_cache);
@@ -636,7 +636,7 @@ class e_pref extends e_front_model
} }
if($save) if($save)
{ {
ecache::set_sys('Config_'.($save !== true ? $save : $this->alias), $cache_string, true); e107::getCache()->set_sys('Config_'.($save !== true ? $save : $this->alias), $cache_string, true);
} }
return $this; return $this;
} }
@@ -654,7 +654,7 @@ class e_pref extends e_front_model
{ {
$this->pref_cache = ''; $this->pref_cache = '';
} }
ecache::clear_sys('Config_'.(!empty($cache_name) ? $cache_name : $this->alias)); e107::getCache()->clear_sys('Config_'.(!empty($cache_name) ? $cache_name : $this->alias));
return $this; return $this;
} }

View File

@@ -1123,7 +1123,7 @@ class themeHandler
$sql->db_Delete("menus", "menu_layout !='' "); $sql->db_Delete("menus", "menu_layout !='' ");
ecache::clear_sys(); e107::getCache()->clear_sys();
if($core->save()) if($core->save())
{ {