Upgrade CakePHP from 2.2.5 to 2.9.5

This commit is contained in:
Brm Ko 2017-02-26 15:29:44 +01:00
parent 5a580df460
commit 235a541597
793 changed files with 60746 additions and 23753 deletions

View file

@ -2,19 +2,18 @@
/**
* Xcache storage engine for cache.
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package Cake.Cache.Engine
* @since CakePHP(tm) v 1.2.0.4947
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
@ -42,10 +41,10 @@ class XcacheEngine extends CacheEngine {
* To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array());
*
* @param array $settings array of setting for the engine
* @return boolean True if the engine has been successfully initialized, false if not
* @return bool True if the engine has been successfully initialized, false if not
*/
public function init($settings = array()) {
if (php_sapi_name() !== 'cli') {
if (PHP_SAPI !== 'cli') {
parent::init(array_merge(array(
'engine' => 'Xcache',
'prefix' => Inflector::slug(APP_DIR) . '_',
@ -63,8 +62,8 @@ class XcacheEngine extends CacheEngine {
*
* @param string $key Identifier for the data
* @param mixed $value Data to be cached
* @param integer $duration How long to cache the data, in seconds
* @return boolean True if the data was successfully cached, false on failure
* @param int $duration How long to cache the data, in seconds
* @return bool True if the data was successfully cached, false on failure
*/
public function write($key, $value, $duration) {
$expires = time() + $duration;
@ -81,7 +80,7 @@ class XcacheEngine extends CacheEngine {
public function read($key) {
if (xcache_isset($key)) {
$time = time();
$cachetime = intval(xcache_get($key . '_expires'));
$cachetime = (int)xcache_get($key . '_expires');
if ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime) {
return false;
}
@ -95,7 +94,7 @@ class XcacheEngine extends CacheEngine {
* If the cache key is not an integer it will be treated as 0
*
* @param string $key Identifier for the data
* @param integer $offset How much to increment
* @param int $offset How much to increment
* @return New incremented value, false otherwise
*/
public function increment($key, $offset = 1) {
@ -107,7 +106,7 @@ class XcacheEngine extends CacheEngine {
* If the cache key is not an integer it will be treated as 0
*
* @param string $key Identifier for the data
* @param integer $offset How much to subtract
* @param int $offset How much to subtract
* @return New decremented value, false otherwise
*/
public function decrement($key, $offset = 1) {
@ -118,7 +117,7 @@ class XcacheEngine extends CacheEngine {
* Delete a key from the cache
*
* @param string $key Identifier for the data
* @return boolean True if the value was successfully deleted, false if it didn't exist or couldn't be removed
* @return bool True if the value was successfully deleted, false if it didn't exist or couldn't be removed
*/
public function delete($key) {
return xcache_unset($key);
@ -127,8 +126,9 @@ class XcacheEngine extends CacheEngine {
/**
* Delete all keys from the cache
*
* @param boolean $check
* @return boolean True if the cache was successfully cleared, false otherwise
* @param bool $check If true no deletes will occur and instead CakePHP will rely
* on key TTL values.
* @return bool True if the cache was successfully cleared, false otherwise
*/
public function clear($check) {
$this->_auth();
@ -146,7 +146,7 @@ class XcacheEngine extends CacheEngine {
* the group accordingly.
*
* @return array
**/
*/
public function groups() {
$result = array();
foreach ($this->settings['groups'] as $group) {
@ -164,8 +164,9 @@ class XcacheEngine extends CacheEngine {
* Increments the group value to simulate deletion of all keys under a group
* old values will remain in storage until they expire.
*
* @return boolean success
**/
* @param string $group The group to clear.
* @return bool success
*/
public function clearGroup($group) {
return (bool)xcache_inc($this->settings['prefix'] . $group, 1);
}
@ -177,7 +178,7 @@ class XcacheEngine extends CacheEngine {
* This has to be done because xcache_clear_cache() needs to pass Basic Http Auth
* (see xcache.admin configuration settings)
*
* @param boolean $reverse Revert changes
* @param bool $reverse Revert changes
* @return void
*/
protected function _auth($reverse = false) {
@ -206,4 +207,21 @@ class XcacheEngine extends CacheEngine {
}
}
}
/**
* Write data for key into cache if it doesn't exist already.
* If it already exists, it fails and returns false.
*
* @param string $key Identifier for the data.
* @param mixed $value Data to be cached.
* @param int $duration How long to cache the data, in seconds.
* @return bool True if the data was successfully cached, false on failure.
*/
public function add($key, $value, $duration) {
$cachedValue = $this->read($key);
if ($cachedValue === false) {
return $this->write($key, $value, $duration);
}
return false;
}
}