@@ -14,7 +14,10 @@ discard block |
||
14 | 14 | namespace EGroupware\Api\Cache; |
15 | 15 | |
16 | 16 | // fix warning in tests, if memcache extension not available |
17 | -if (defined('MEMCACHE_COMPRESSED')) define('MEMCACHE_COMPRESSED', 2); |
|
17 | +if (defined('MEMCACHE_COMPRESSED')) |
|
18 | +{ |
|
19 | + define('MEMCACHE_COMPRESSED', 2); |
|
20 | +} |
|
18 | 21 | |
19 | 22 | /** |
20 | 23 | * Caching provider storing data in memcached via PHP's memcache extension |
@@ -62,7 +65,11 @@ discard block |
||
62 | 65 | check_load_extension('memcache',true); |
63 | 66 | $this->memcache = new \Memcache(); |
64 | 67 | |
65 | - if (!$params) $params = array('localhost'); // some reasonable default |
|
68 | + if (!$params) |
|
69 | + { |
|
70 | + $params = array('localhost'); |
|
71 | + } |
|
72 | + // some reasonable default |
|
66 | 73 | |
67 | 74 | $ok = false; |
68 | 75 | foreach($params as $host_port) |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @var array |
84 | 84 | */ |
85 | - static $default_provider; // = array('EGroupware\Api\Cache\Files');// array('EGroupware\Api\Cache\Memcache','localhost'); |
|
85 | + static $default_provider; // = array('EGroupware\Api\Cache\Files');// array('EGroupware\Api\Cache\Memcache','localhost'); |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Maximum expiration time, if set unlimited expiration (=0) or bigger expiration times are replaced with that time |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | * @param int $expiration =0 expiration time in seconds, default 0 = never |
109 | 109 | * @return boolean true if data could be stored, false otherwise incl. key already existed |
110 | 110 | */ |
111 | - static public function addCache($level,$app,$location,$data,$expiration=0) |
|
111 | + static public function addCache($level, $app, $location, $data, $expiration = 0) |
|
112 | 112 | { |
113 | 113 | //error_log(__METHOD__."('$level','$app','$location',".array2string($data).",$expiration)"); |
114 | - switch($level) |
|
114 | + switch ($level) |
|
115 | 115 | { |
116 | 116 | case self::SESSION: |
117 | 117 | case self::REQUEST: |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | { |
130 | 130 | $expiration = self::$max_expiration; |
131 | 131 | } |
132 | - return $provider->add(self::keys($level,$app,$location),$data,$expiration); |
|
132 | + return $provider->add(self::keys($level, $app, $location), $data, $expiration); |
|
133 | 133 | } |
134 | 134 | throw new Exception\WrongParameter(__METHOD__."() unknown level '$level'!"); |
135 | 135 | } |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | * @param int $expiration =0 expiration time in seconds, default 0 = never |
145 | 145 | * @return boolean true if data could be stored, false otherwise |
146 | 146 | */ |
147 | - static public function setCache($level,$app,$location,$data,$expiration=0) |
|
147 | + static public function setCache($level, $app, $location, $data, $expiration = 0) |
|
148 | 148 | { |
149 | 149 | //error_log(__METHOD__."('$level','$app','$location',".array2string($data).",$expiration)"); |
150 | - switch($level) |
|
150 | + switch ($level) |
|
151 | 151 | { |
152 | 152 | case self::SESSION: |
153 | 153 | case self::REQUEST: |
154 | - return call_user_func(array(__CLASS__,'set'.$level),$app,$location,$data,$expiration); |
|
154 | + return call_user_func(array(__CLASS__, 'set'.$level), $app, $location, $data, $expiration); |
|
155 | 155 | |
156 | 156 | case self::INSTANCE: |
157 | 157 | case self::TREE: |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | { |
166 | 166 | $expiration = self::$max_expiration; |
167 | 167 | } |
168 | - return $provider->set(self::keys($level,$app,$location),$data,$expiration); |
|
168 | + return $provider->set(self::keys($level, $app, $location), $data, $expiration); |
|
169 | 169 | } |
170 | 170 | throw new Exception\WrongParameter(__METHOD__."() unknown level '$level'!"); |
171 | 171 | } |
@@ -182,15 +182,15 @@ discard block |
||
182 | 182 | * @return mixed NULL if data not found in cache (and no callback specified) or |
183 | 183 | * if $location is an array: location => data pairs for existing location-data, non-existing is not returned |
184 | 184 | */ |
185 | - static public function getCache($level,$app,$location,$callback=null,array $callback_params=array(),$expiration=0) |
|
185 | + static public function getCache($level, $app, $location, $callback = null, array $callback_params = array(), $expiration = 0) |
|
186 | 186 | { |
187 | - switch($level) |
|
187 | + switch ($level) |
|
188 | 188 | { |
189 | 189 | case self::SESSION: |
190 | 190 | case self::REQUEST: |
191 | - foreach((array)$location as $l) |
|
191 | + foreach ((array)$location as $l) |
|
192 | 192 | { |
193 | - $data[$l] = call_user_func(array(__CLASS__,'get'.$level),$app,$l,$callback,$callback_params,$expiration); |
|
193 | + $data[$l] = call_user_func(array(__CLASS__, 'get'.$level), $app, $l, $callback, $callback_params, $expiration); |
|
194 | 194 | } |
195 | 195 | return is_array($location) ? $data : $data[$l]; |
196 | 196 | |
@@ -210,34 +210,34 @@ discard block |
||
210 | 210 | } |
211 | 211 | if (is_a($provider, 'EGroupware\Api\Cache\ProviderMultiple')) |
212 | 212 | { |
213 | - $data = $provider->mget($keys=self::keys($level,$app,$location)); |
|
213 | + $data = $provider->mget($keys = self::keys($level, $app, $location)); |
|
214 | 214 | } |
215 | 215 | else // default implementation calls get multiple times |
216 | 216 | { |
217 | 217 | $data = array(); |
218 | - foreach($location as $l) |
|
218 | + foreach ($location as $l) |
|
219 | 219 | { |
220 | - $data[$l] = $provider->get($keys=self::keys($level,$app,$l)); |
|
220 | + $data[$l] = $provider->get($keys = self::keys($level, $app, $l)); |
|
221 | 221 | if (!isset($data[$l])) unset($data[$l]); |
222 | 222 | } |
223 | 223 | } |
224 | 224 | } |
225 | 225 | else |
226 | 226 | { |
227 | - $data = $provider->get($keys=self::keys($level,$app,$location)); |
|
227 | + $data = $provider->get($keys = self::keys($level, $app, $location)); |
|
228 | 228 | if (is_null($data) && !is_null($callback)) |
229 | 229 | { |
230 | - $data = call_user_func_array($callback,$callback_params); |
|
230 | + $data = call_user_func_array($callback, $callback_params); |
|
231 | 231 | // limit expiration to configured maximum time |
232 | 232 | if (isset(self::$max_expiration) && (!$expiration || $expiration > self::$max_expiration)) |
233 | 233 | { |
234 | 234 | $expiration = self::$max_expiration; |
235 | 235 | } |
236 | - $provider->set($keys,$data,$expiration); |
|
236 | + $provider->set($keys, $data, $expiration); |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | } |
240 | - catch(Exception $e) { |
|
240 | + catch (Exception $e) { |
|
241 | 241 | unset($e); |
242 | 242 | $data = null; |
243 | 243 | } |
@@ -254,13 +254,13 @@ discard block |
||
254 | 254 | * @param string $location location name for data |
255 | 255 | * @return boolean true if data was set, false if not (like isset()) |
256 | 256 | */ |
257 | - static public function unsetCache($level,$app,$location) |
|
257 | + static public function unsetCache($level, $app, $location) |
|
258 | 258 | { |
259 | - switch($level) |
|
259 | + switch ($level) |
|
260 | 260 | { |
261 | 261 | case self::SESSION: |
262 | 262 | case self::REQUEST: |
263 | - return call_user_func(array(__CLASS__,'unset'.$level),$app,$location); |
|
263 | + return call_user_func(array(__CLASS__, 'unset'.$level), $app, $location); |
|
264 | 264 | |
265 | 265 | case self::INSTANCE: |
266 | 266 | case self::TREE: |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | { |
270 | 270 | return false; |
271 | 271 | } |
272 | - return $provider->delete(self::keys($level,$app,$location)); |
|
272 | + return $provider->delete(self::keys($level, $app, $location)); |
|
273 | 273 | } |
274 | 274 | throw new Exception\WrongParameter(__METHOD__."() unknown level '$level'!"); |
275 | 275 | } |
@@ -283,10 +283,10 @@ discard block |
||
283 | 283 | * @param int $expiration =0 expiration time in seconds, default 0 = never |
284 | 284 | * @return boolean true if data could be stored, false otherwise |
285 | 285 | */ |
286 | - static public function setTree($app,$location,$data,$expiration=0) |
|
286 | + static public function setTree($app, $location, $data, $expiration = 0) |
|
287 | 287 | { |
288 | 288 | //error_log(__METHOD__."('$app','$location',".array2string($data).",$expiration)"); |
289 | - return self::setCache(self::TREE,$app,$location,$data,$expiration); |
|
289 | + return self::setCache(self::TREE, $app, $location, $data, $expiration); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -299,9 +299,9 @@ discard block |
||
299 | 299 | * @param int $expiration =0 expiration time in seconds, default 0 = never |
300 | 300 | * @return mixed NULL if data not found in cache (and no callback specified) |
301 | 301 | */ |
302 | - static public function getTree($app,$location,$callback=null,array $callback_params=array(),$expiration=0) |
|
302 | + static public function getTree($app, $location, $callback = null, array $callback_params = array(), $expiration = 0) |
|
303 | 303 | { |
304 | - return self::getCache(self::TREE,$app,$location,$callback,$callback_params,$expiration); |
|
304 | + return self::getCache(self::TREE, $app, $location, $callback, $callback_params, $expiration); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | * @param string $location location name for data |
312 | 312 | * @return boolean true if data was set, false if not (like isset()) |
313 | 313 | */ |
314 | - static public function unsetTree($app,$location) |
|
314 | + static public function unsetTree($app, $location) |
|
315 | 315 | { |
316 | - return self::unsetCache(self::TREE,$app,$location); |
|
316 | + return self::unsetCache(self::TREE, $app, $location); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -325,9 +325,9 @@ discard block |
||
325 | 325 | * @param int $expiration =0 expiration time in seconds, default 0 = never |
326 | 326 | * @return boolean true if data could be stored, false otherwise |
327 | 327 | */ |
328 | - static public function setInstance($app,$location,$data,$expiration=0) |
|
328 | + static public function setInstance($app, $location, $data, $expiration = 0) |
|
329 | 329 | { |
330 | - return self::setCache(self::INSTANCE,$app,$location,$data,$expiration); |
|
330 | + return self::setCache(self::INSTANCE, $app, $location, $data, $expiration); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | * @param int $expiration =0 expiration time in seconds, default 0 = never |
341 | 341 | * @return mixed NULL if data not found in cache (and no callback specified) |
342 | 342 | */ |
343 | - static public function getInstance($app,$location,$callback=null,array $callback_params=array(),$expiration=0) |
|
343 | + static public function getInstance($app, $location, $callback = null, array $callback_params = array(), $expiration = 0) |
|
344 | 344 | { |
345 | - return self::getCache(self::INSTANCE,$app,$location,$callback,$callback_params,$expiration); |
|
345 | + return self::getCache(self::INSTANCE, $app, $location, $callback, $callback_params, $expiration); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -352,9 +352,9 @@ discard block |
||
352 | 352 | * @param string $location location name for data |
353 | 353 | * @return boolean true if data was set, false if not (like isset()) |
354 | 354 | */ |
355 | - static public function unsetInstance($app,$location) |
|
355 | + static public function unsetInstance($app, $location) |
|
356 | 356 | { |
357 | - return self::unsetCache(self::INSTANCE,$app,$location); |
|
357 | + return self::unsetCache(self::INSTANCE, $app, $location); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | /** |
@@ -371,18 +371,18 @@ discard block |
||
371 | 371 | * @param int $expiration =0 expiration time in seconds, default 0 = never |
372 | 372 | * @return boolean true if data could be stored, false otherwise |
373 | 373 | */ |
374 | - static public function setSession($app,$location,$data,$expiration=0) |
|
374 | + static public function setSession($app, $location, $data, $expiration = 0) |
|
375 | 375 | { |
376 | 376 | if (isset($_SESSION[Session::EGW_SESSION_ENCRYPTED])) |
377 | 377 | { |
378 | 378 | if (Session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!'); |
379 | - return false; // can no longer store something in the session, eg. because commit_session() was called |
|
379 | + return false; // can no longer store something in the session, eg. because commit_session() was called |
|
380 | 380 | } |
381 | 381 | $_SESSION[Session::EGW_APPSESSION_VAR][$app][$location] = $data; |
382 | 382 | |
383 | 383 | if ($expiration > 0) |
384 | 384 | { |
385 | - $_SESSION[Session::EGW_APPSESSION_VAR][self::SESSION_EXPIRATION_PREFIX.$app][$location] = time()+$expiration; |
|
385 | + $_SESSION[Session::EGW_APPSESSION_VAR][self::SESSION_EXPIRATION_PREFIX.$app][$location] = time() + $expiration; |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | return true; |
@@ -400,12 +400,12 @@ discard block |
||
400 | 400 | * @param int $expiration =0 expiration time in seconds, default 0 = never |
401 | 401 | * @return mixed NULL if data not found in cache (and no callback specified) |
402 | 402 | */ |
403 | - static public function &getSession($app,$location,$callback=null,array $callback_params=array(),$expiration=0) |
|
403 | + static public function &getSession($app, $location, $callback = null, array $callback_params = array(), $expiration = 0) |
|
404 | 404 | { |
405 | 405 | if (isset($_SESSION[Session::EGW_SESSION_ENCRYPTED])) |
406 | 406 | { |
407 | 407 | if (Session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!'); |
408 | - return null; // can no longer store something in the session, eg. because commit_session() was called |
|
408 | + return null; // can no longer store something in the session, eg. because commit_session() was called |
|
409 | 409 | } |
410 | 410 | // check if entry is expired and clean it up in that case |
411 | 411 | if (isset($_SESSION[Session::EGW_APPSESSION_VAR][self::SESSION_EXPIRATION_PREFIX.$app][$location]) && |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | } |
417 | 417 | if (!isset($_SESSION[Session::EGW_APPSESSION_VAR][$app][$location]) && !is_null($callback)) |
418 | 418 | { |
419 | - $_SESSION[Session::EGW_APPSESSION_VAR][$app][$location] = call_user_func_array($callback,$callback_params); |
|
419 | + $_SESSION[Session::EGW_APPSESSION_VAR][$app][$location] = call_user_func_array($callback, $callback_params); |
|
420 | 420 | } |
421 | 421 | return $_SESSION[Session::EGW_APPSESSION_VAR][$app][$location]; |
422 | 422 | } |
@@ -428,12 +428,12 @@ discard block |
||
428 | 428 | * @param string $location location name for data |
429 | 429 | * @return boolean true if data was set, false if not (like isset()) |
430 | 430 | */ |
431 | - static public function unsetSession($app,$location) |
|
431 | + static public function unsetSession($app, $location) |
|
432 | 432 | { |
433 | 433 | if (isset($_SESSION[Session::EGW_SESSION_ENCRYPTED])) |
434 | 434 | { |
435 | 435 | if (Session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!'); |
436 | - return false; // can no longer store something in the session, eg. because commit_session() was called |
|
436 | + return false; // can no longer store something in the session, eg. because commit_session() was called |
|
437 | 437 | } |
438 | 438 | // check if entry is expired and clean it up in that case |
439 | 439 | if (isset($_SESSION[Session::EGW_APPSESSION_VAR][self::SESSION_EXPIRATION_PREFIX.$app][$location]) && |
@@ -467,9 +467,9 @@ discard block |
||
467 | 467 | * @param int $expiration =0 expiration time is NOT used for REQUEST! |
468 | 468 | * @return boolean true if data could be stored, false otherwise |
469 | 469 | */ |
470 | - static public function setRequest($app,$location,$data,$expiration=0) |
|
470 | + static public function setRequest($app, $location, $data, $expiration = 0) |
|
471 | 471 | { |
472 | - unset($expiration); // not used, but required by function signature |
|
472 | + unset($expiration); // not used, but required by function signature |
|
473 | 473 | self::$request_cache[$app][$location] = $data; |
474 | 474 | |
475 | 475 | return true; |
@@ -485,12 +485,12 @@ discard block |
||
485 | 485 | * @param int $expiration =0 expiration time is NOT used for REQUEST! |
486 | 486 | * @return mixed NULL if data not found in cache (and no callback specified) |
487 | 487 | */ |
488 | - static public function getRequest($app,$location,$callback=null,array $callback_params=array(),$expiration=0) |
|
488 | + static public function getRequest($app, $location, $callback = null, array $callback_params = array(), $expiration = 0) |
|
489 | 489 | { |
490 | - unset($expiration); // not used, but required by function signature |
|
490 | + unset($expiration); // not used, but required by function signature |
|
491 | 491 | if (!isset(self::$request_cache[$app][$location]) && !is_null($callback)) |
492 | 492 | { |
493 | - self::$request_cache[$app][$location] = call_user_func_array($callback,$callback_params); |
|
493 | + self::$request_cache[$app][$location] = call_user_func_array($callback, $callback_params); |
|
494 | 494 | } |
495 | 495 | return self::$request_cache[$app][$location]; |
496 | 496 | } |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | * @param string $location location name for data |
503 | 503 | * @return boolean true if data was set, false if not (like isset()) |
504 | 504 | */ |
505 | - static public function unsetRequest($app,$location) |
|
505 | + static public function unsetRequest($app, $location) |
|
506 | 506 | { |
507 | 507 | if (!isset(self::$request_cache[$app][$location])) |
508 | 508 | { |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | * @param boolean $log_not_found =true false do not log if no provider found, used eg. to supress error via unsetCache during installation |
523 | 523 | * @return Api\Cache\Provider |
524 | 524 | */ |
525 | - static protected function get_provider($level, $log_not_found=true) |
|
525 | + static protected function get_provider($level, $log_not_found = true) |
|
526 | 526 | { |
527 | 527 | static $providers = array(); |
528 | 528 | |
@@ -543,13 +543,13 @@ discard block |
||
543 | 543 | } |
544 | 544 | else |
545 | 545 | { |
546 | - $providers[$level] = false; // no provider specified |
|
546 | + $providers[$level] = false; // no provider specified |
|
547 | 547 | $reason = 'no provider specified'; |
548 | 548 | } |
549 | 549 | } |
550 | 550 | elseif (!$params) |
551 | 551 | { |
552 | - $providers[$level] = false; // cache for $level disabled |
|
552 | + $providers[$level] = false; // cache for $level disabled |
|
553 | 553 | $reason = "cache for $level disabled"; |
554 | 554 | } |
555 | 555 | else |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | $class = array_shift($params); |
560 | 560 | if (!class_exists($class)) |
561 | 561 | { |
562 | - $providers[$level] = false; // provider class not found |
|
562 | + $providers[$level] = false; // provider class not found |
|
563 | 563 | $reason = "provider $class not found"; |
564 | 564 | } |
565 | 565 | else |
@@ -568,9 +568,9 @@ discard block |
||
568 | 568 | { |
569 | 569 | $providers[$level] = new $class($params); |
570 | 570 | } |
571 | - catch(Exception $e) |
|
571 | + catch (Exception $e) |
|
572 | 572 | { |
573 | - $providers[$level] = false; // eg. could not open connection to backend |
|
573 | + $providers[$level] = false; // eg. could not open connection to backend |
|
574 | 574 | $reason = "error instanciating provider $class: ".$e->getMessage(); |
575 | 575 | } |
576 | 576 | } |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | * @param string $level |
588 | 588 | * @return string class-name of provider |
589 | 589 | */ |
590 | - public static function getProvider($level=self::INSTANCE) |
|
590 | + public static function getProvider($level = self::INSTANCE) |
|
591 | 591 | { |
592 | 592 | $provider = self::get_provider($level); |
593 | 593 | |
@@ -601,35 +601,35 @@ discard block |
||
601 | 601 | * @param boolean $throw =true throw an exception, if we can't retriev the value |
602 | 602 | * @return string|boolean string with config or false if not found and !$throw |
603 | 603 | */ |
604 | - static public function get_system_config($name,$throw=true) |
|
604 | + static public function get_system_config($name, $throw = true) |
|
605 | 605 | { |
606 | - if(!isset($GLOBALS['egw_info']['server'][$name])) |
|
606 | + if (!isset($GLOBALS['egw_info']['server'][$name])) |
|
607 | 607 | { |
608 | 608 | if (isset($GLOBALS['egw_setup']) && isset($GLOBALS['egw_setup']->db) || $GLOBALS['egw']->db) |
609 | 609 | { |
610 | 610 | $db = $GLOBALS['egw']->db ? $GLOBALS['egw']->db : $GLOBALS['egw_setup']->db; |
611 | 611 | |
612 | 612 | try { |
613 | - if (($rs = $db->select(Config::TABLE,'config_value',array( |
|
613 | + if (($rs = $db->select(Config::TABLE, 'config_value', array( |
|
614 | 614 | 'config_app' => 'phpgwapi', |
615 | 615 | 'config_name' => $name, |
616 | - ),__LINE__,__FILE__))) |
|
616 | + ), __LINE__, __FILE__))) |
|
617 | 617 | { |
618 | 618 | $GLOBALS['egw_info']['server'][$name] = $rs->fetchColumn(); |
619 | 619 | } |
620 | 620 | else |
621 | 621 | { |
622 | - error_log(__METHOD__."('$name', $throw) config value NOT found!");//.function_backtrace()); |
|
622 | + error_log(__METHOD__."('$name', $throw) config value NOT found!"); //.function_backtrace()); |
|
623 | 623 | } |
624 | 624 | } |
625 | - catch(Db\Exception $e) |
|
625 | + catch (Db\Exception $e) |
|
626 | 626 | { |
627 | - if ($throw) error_log(__METHOD__."('$name', $throw) cound NOT query value: ".$e->getMessage());//.function_backtrace()); |
|
627 | + if ($throw) error_log(__METHOD__."('$name', $throw) cound NOT query value: ".$e->getMessage()); //.function_backtrace()); |
|
628 | 628 | } |
629 | 629 | } |
630 | 630 | if (!$GLOBALS['egw_info']['server'][$name] && $throw) |
631 | 631 | { |
632 | - throw new Exception (__METHOD__."($name) \$GLOBALS['egw_info']['server']['$name'] is NOT set!"); |
|
632 | + throw new Exception(__METHOD__."($name) \$GLOBALS['egw_info']['server']['$name'] is NOT set!"); |
|
633 | 633 | } |
634 | 634 | } |
635 | 635 | return $GLOBALS['egw_info']['server'][$name]; |
@@ -641,7 +641,7 @@ discard block |
||
641 | 641 | * @param string $level =self::INSTANCE |
642 | 642 | * @param string $app =null app-name or "all" to empty complete cache |
643 | 643 | */ |
644 | - static public function flush($level=self::INSTANCE, $app=null) |
|
644 | + static public function flush($level = self::INSTANCE, $app = null) |
|
645 | 645 | { |
646 | 646 | $ret = true; |
647 | 647 | if (!($provider = self::get_provider($level))) |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | * @param string $install_id =null default use install_id of current instance |
689 | 689 | * @return string new key also stored in self::$instance_key |
690 | 690 | */ |
691 | - static public function generate_instance_key($install_id=null) |
|
691 | + static public function generate_instance_key($install_id = null) |
|
692 | 692 | { |
693 | 693 | if (!isset($install_id)) |
694 | 694 | { |
@@ -710,18 +710,18 @@ discard block |
||
710 | 710 | * @param string $location =null |
711 | 711 | * @return array |
712 | 712 | */ |
713 | - static public function keys($level, $app=null, $location=null) |
|
713 | + static public function keys($level, $app = null, $location = null) |
|
714 | 714 | { |
715 | 715 | static $tree_key = null; |
716 | 716 | |
717 | - switch($level) |
|
717 | + switch ($level) |
|
718 | 718 | { |
719 | 719 | case self::TREE: |
720 | 720 | if (!isset($tree_key)) |
721 | 721 | { |
722 | - $tree_key = $level.'-'.str_replace(array(':','/','\\'),'-', self::$egw_server_root); |
|
722 | + $tree_key = $level.'-'.str_replace(array(':', '/', '\\'), '-', self::$egw_server_root); |
|
723 | 723 | // add charset to key, if not utf-8 (as everything we store depends on charset!) |
724 | - if (($charset = self::get_system_config('system_charset',false)) && $charset != 'utf-8') |
|
724 | + if (($charset = self::get_system_config('system_charset', false)) && $charset != 'utf-8') |
|
725 | 725 | { |
726 | 726 | $tree_key .= '-'.$charset; |
727 | 727 | } |
@@ -769,10 +769,7 @@ discard block |
||
769 | 769 | if (is_null(Cache::$default_provider)) |
770 | 770 | { |
771 | 771 | Cache::$default_provider = |
772 | - PHP_SAPI === 'cli' ? 'EGroupware\Api\Cache\Files' : |
|
773 | - (function_exists('apcu_fetch') && Cache\Apcu::available() ? 'EGroupware\Api\Cache\Apcu' : |
|
774 | - (function_exists('apc_fetch') && Cache\Apc::available() ? 'EGroupware\Api\Cache\Apc' : |
|
775 | - 'EGroupware\Api\Cache\Files')); |
|
772 | + PHP_SAPI === 'cli' ? 'EGroupware\Api\Cache\Files' : (function_exists('apcu_fetch') && Cache\Apcu::available() ? 'EGroupware\Api\Cache\Apcu' : (function_exists('apc_fetch') && Cache\Apc::available() ? 'EGroupware\Api\Cache\Apc' : 'EGroupware\Api\Cache\Files')); |
|
776 | 773 | } |
777 | 774 | |
778 | 775 | //error_log('Cache::$default_provider='.array2string(Cache::$default_provider)); |