* Setup: fixed (partially) stalled installation, because caching could not find not yet created configuration

This commit is contained in:
Ralf Becker 2014-05-05 12:33:33 +00:00
parent 5f786d9af3
commit 6f98614b15
2 changed files with 28 additions and 14 deletions

View File

@ -188,6 +188,7 @@ class egw_cache
} }
} }
catch(Exception $e) { catch(Exception $e) {
unset($e);
$data = null; $data = null;
} }
return $data; return $data;
@ -213,7 +214,7 @@ class egw_cache
case self::INSTANCE: case self::INSTANCE:
case self::TREE: case self::TREE:
if (!($provider = self::get_provider($level))) if (!($provider = self::get_provider($level, false)))
{ {
return false; return false;
} }
@ -316,6 +317,7 @@ class egw_cache
*/ */
static public function setSession($app,$location,$data,$expiration=0) static public function setSession($app,$location,$data,$expiration=0)
{ {
unset($expiration); // not used, but required by function signature
if (isset($_SESSION[egw_session::EGW_SESSION_ENCRYPTED])) if (isset($_SESSION[egw_session::EGW_SESSION_ENCRYPTED]))
{ {
if (egw_session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!'); if (egw_session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!');
@ -340,6 +342,7 @@ class egw_cache
*/ */
static public function &getSession($app,$location,$callback=null,array $callback_params=array(),$expiration=0) static public function &getSession($app,$location,$callback=null,array $callback_params=array(),$expiration=0)
{ {
unset($expiration); // not used, but required by function signature
if (isset($_SESSION[egw_session::EGW_SESSION_ENCRYPTED])) if (isset($_SESSION[egw_session::EGW_SESSION_ENCRYPTED]))
{ {
if (egw_session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!'); if (egw_session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!');
@ -393,6 +396,7 @@ class egw_cache
*/ */
static public function setRequest($app,$location,$data,$expiration=0) static public function setRequest($app,$location,$data,$expiration=0)
{ {
unset($expiration); // not used, but required by function signature
self::$request_cache[$app][$location] = $data; self::$request_cache[$app][$location] = $data;
return true; return true;
@ -410,6 +414,7 @@ class egw_cache
*/ */
static public function getRequest($app,$location,$callback=null,array $callback_params=array(),$expiration=0) static public function getRequest($app,$location,$callback=null,array $callback_params=array(),$expiration=0)
{ {
unset($expiration); // not used, but required by function signature
if (!isset(self::$request_cache[$app][$location]) && !is_null($callback)) if (!isset(self::$request_cache[$app][$location]) && !is_null($callback))
{ {
self::$request_cache[$app][$location] = call_user_func_array($callback,$callback_params); self::$request_cache[$app][$location] = call_user_func_array($callback,$callback_params);
@ -432,7 +437,7 @@ class egw_cache
} }
unset(self::$request_cache[$app][$location]); unset(self::$request_cache[$app][$location]);
return $ret; return true;
} }
/** /**
@ -441,9 +446,10 @@ class egw_cache
* The returned provider already has an opened connection * The returned provider already has an opened connection
* *
* @param string $level egw_cache::(TREE|INSTANCE) * @param string $level egw_cache::(TREE|INSTANCE)
* @param boolean $log_not_found=true false do not log if no provider found, used eg. to supress error via unsetCache during installation
* @return egw_cache_provider * @return egw_cache_provider
*/ */
static protected function get_provider($level) static protected function get_provider($level, $log_not_found=true)
{ {
static $providers = array(); static $providers = array();
@ -494,7 +500,7 @@ class egw_cache
} }
} }
} }
if (!$providers[$level]) error_log(__METHOD__."($level) no provider found ($reason)!"); if (!$providers[$level] && $log_not_found) error_log(__METHOD__."($level) no provider found ($reason)!".function_backtrace());
} }
//error_log(__METHOD__."($level) = ".array2string($providers[$level]).', cache_provider='.array2string($GLOBALS['egw_info']['server']['cache_provider_'.strtolower($level)])); //error_log(__METHOD__."($level) = ".array2string($providers[$level]).', cache_provider='.array2string($GLOBALS['egw_info']['server']['cache_provider_'.strtolower($level)]));
return $providers[$level]; return $providers[$level];
@ -515,16 +521,22 @@ class egw_cache
{ {
$db = $GLOBALS['egw']->db ? $GLOBALS['egw']->db : $GLOBALS['egw_setup']->db; $db = $GLOBALS['egw']->db ? $GLOBALS['egw']->db : $GLOBALS['egw_setup']->db;
if (($rs = $db->select(config::TABLE,'config_value',array( try {
'config_app' => 'phpgwapi', if (($rs = $db->select(config::TABLE,'config_value',array(
'config_name' => $name, 'config_app' => 'phpgwapi',
),__LINE__,__FILE__))) 'config_name' => $name,
{ ),__LINE__,__FILE__)))
$GLOBALS['egw_info']['server'][$name] = $rs->fetchColumn(); {
$GLOBALS['egw_info']['server'][$name] = $rs->fetchColumn();
}
else
{
error_log(__METHOD__."('$name', $throw) config value NOT found!");//.function_backtrace());
}
} }
else catch(egw_exception_db $e)
{ {
error_log(__METHOD__."('name', $throw) cound NOT query value!"); if ($throw) error_log(__METHOD__."('$name', $throw) cound NOT query value: ".$e->getMessage());//.function_backtrace());
} }
} }
if (!$GLOBALS['egw_info']['server'][$name] && $throw) if (!$GLOBALS['egw_info']['server'][$name] && $throw)
@ -837,6 +849,7 @@ abstract class egw_cache_provider_check implements egw_cache_provider
*/ */
function flush(array $keys) function flush(array $keys)
{ {
unset($keys); // required by function signature
return false; return false;
} }
} }

View File

@ -45,7 +45,8 @@ class egw_cache_files extends egw_cache_provider_check implements egw_cache_prov
} }
else else
{ {
$this->base_path = egw_cache::get_system_config('temp_dir').'/egw_cache'; $this->base_path = egw_cache::get_system_config('temp_dir', false);
if (isset($this->base_path)) $this->base_path .= '/egw_cache';
} }
if (!isset($this->base_path) || !file_exists($this->base_path) && !mkdir($this->base_path,0700,true)) if (!isset($this->base_path) || !file_exists($this->base_path) && !mkdir($this->base_path,0700,true))
{ {
@ -63,7 +64,7 @@ class egw_cache_files extends egw_cache_provider_check implements egw_cache_prov
*/ */
function set(array $keys,$data,$expiration=0) function set(array $keys,$data,$expiration=0)
{ {
if ($ret = @file_put_contents($fname=$this->filename($keys,true),serialize($data),LOCK_EX) > 0) if (($ret = @file_put_contents($fname=$this->filename($keys,true),serialize($data),LOCK_EX) > 0))
{ {
if ((int)$expiration > 0) file_put_contents($fname.self::EXPIRATION_EXTENSION,(string)$expiration); if ((int)$expiration > 0) file_put_contents($fname.self::EXPIRATION_EXTENSION,(string)$expiration);
} }