mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge branch '1.3-misc' into 1.3-merger
Conflicts: cake/libs/view/helpers/html.php
This commit is contained in:
commit
8cdee90b4f
22 changed files with 418 additions and 372 deletions
|
@ -149,6 +149,9 @@ class ProjectTask extends Shell {
|
||||||
$verbose = $this->in(__('Do you want verbose output?', true), array('y', 'n'), 'n');
|
$verbose = $this->in(__('Do you want verbose output?', true), array('y', 'n'), 'n');
|
||||||
|
|
||||||
$Folder = new Folder($skel);
|
$Folder = new Folder($skel);
|
||||||
|
if (!empty($this->params['empty'])) {
|
||||||
|
$skip = array();
|
||||||
|
}
|
||||||
if ($Folder->copy(array('to' => $path, 'skip' => $skip))) {
|
if ($Folder->copy(array('to' => $path, 'skip' => $skip))) {
|
||||||
$this->hr();
|
$this->hr();
|
||||||
$this->out(sprintf(__("Created: %s in %s", true), $app, $path));
|
$this->out(sprintf(__("Created: %s in %s", true), $app, $path));
|
||||||
|
|
0
cake/console/templates/skel/libs/empty
Normal file
0
cake/console/templates/skel/libs/empty
Normal file
|
@ -27,16 +27,10 @@
|
||||||
*/
|
*/
|
||||||
class Cache {
|
class Cache {
|
||||||
|
|
||||||
/**
|
|
||||||
* Cache engine to use
|
|
||||||
*
|
|
||||||
* @var CacheEngine
|
|
||||||
* @access protected
|
|
||||||
*/
|
|
||||||
var $_Engine = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache configuration stack
|
* Cache configuration stack
|
||||||
|
* Keeps the permanent/default settings for each cache engine.
|
||||||
|
* These settings are used to reset the engines after temporary modification.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
|
@ -44,7 +38,7 @@ class Cache {
|
||||||
var $__config = array();
|
var $__config = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds name of the current configuration being used
|
* Holds name of the current configuration name being used.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
|
@ -52,13 +46,20 @@ class Cache {
|
||||||
var $__name = 'default';
|
var $__name = 'default';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* whether to reset the settings with the next call to self::set();
|
* Whether to reset the settings with the next call to Cache::set();
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $__reset = false;
|
var $__reset = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Engine instances keyed by configuration name.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
var $_engines = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a singleton instance
|
* Returns a singleton instance
|
||||||
*
|
*
|
||||||
|
@ -75,7 +76,18 @@ class Cache {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the cache configuration to use
|
* Set the cache configuration to use. config() can
|
||||||
|
* both create new configurations, return the settings for already configured
|
||||||
|
* configurations. It also sets the 'default' configuration to use for subsequent
|
||||||
|
* operations.
|
||||||
|
*
|
||||||
|
* To create a new configuration:
|
||||||
|
*
|
||||||
|
* `Cache::config('my_config', array('engine' => 'File', 'path' => TMP));`
|
||||||
|
*
|
||||||
|
* To get the settings for a configuration, and set it as the currently selected configuration
|
||||||
|
*
|
||||||
|
* `Cache::config('default');`
|
||||||
*
|
*
|
||||||
* @see app/config/core.php for configuration settings
|
* @see app/config/core.php for configuration settings
|
||||||
* @param string $name Name of the configuration
|
* @param string $name Name of the configuration
|
||||||
|
@ -85,51 +97,74 @@ class Cache {
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
function config($name = null, $settings = array()) {
|
function config($name = null, $settings = array()) {
|
||||||
$_this =& Cache::getInstance();
|
$self =& Cache::getInstance();
|
||||||
if (is_array($name)) {
|
if (is_array($name)) {
|
||||||
$settings = $name;
|
$settings = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($name === null || !is_string($name)) {
|
if ($name === null || !is_string($name)) {
|
||||||
$name = $_this->__name;
|
$name = $self->__name;
|
||||||
}
|
}
|
||||||
|
|
||||||
$current = array();
|
$current = array();
|
||||||
if (isset($_this->__config[$name])) {
|
if (isset($self->__config[$name])) {
|
||||||
$current = $_this->__config[$name];
|
$current = $self->__config[$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($settings)) {
|
if (!empty($settings)) {
|
||||||
$_this->__name = null;
|
$self->__config[$name] = array_merge($current, $settings);
|
||||||
$_this->__config[$name] = array_merge($current, $settings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($_this->__config[$name]['engine'])) {
|
if (empty($self->__config[$name]['engine'])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$_this->__name = $name;
|
$self->__name = $name;
|
||||||
$engine = $_this->__config[$name]['engine'];
|
$engine = $self->__config[$name]['engine'];
|
||||||
|
|
||||||
if (!$_this->isInitialized($engine)) {
|
if (!isset($self->_engines[$name])) {
|
||||||
if ($_this->engine($engine, $_this->__config[$name]) === false) {
|
$self->_buildEngine($name);
|
||||||
return false;
|
$settings = $self->__config[$name] = $self->settings($name);
|
||||||
}
|
} elseif ($settings = $self->set($self->__config[$name])) {
|
||||||
$settings = $_this->__config[$name] = $_this->settings($engine);
|
$self->__config[$name] = $settings;
|
||||||
} else if ($settings = $_this->set($_this->__config[$name])) {
|
|
||||||
$_this->__config[$name] = $settings;
|
|
||||||
}
|
}
|
||||||
return compact('engine', 'settings');
|
return compact('engine', 'settings');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds and builds the instance of the required engine class.
|
||||||
|
*
|
||||||
|
* @param string $name Name of the config array that needs an engine instance built
|
||||||
|
* @return void
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function _buildEngine($name) {
|
||||||
|
$config = $this->__config[$name];
|
||||||
|
|
||||||
|
list($plugin, $class) = pluginSplit($config['engine']);
|
||||||
|
$cacheClass = $class . 'Engine';
|
||||||
|
if (!class_exists($cacheClass) && $this->__loadEngine($class, $plugin) === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$cacheClass = $class . 'Engine';
|
||||||
|
$this->_engines[$name] =& new $cacheClass();
|
||||||
|
if ($this->_engines[$name]->init($config)) {
|
||||||
|
if (time() % $this->_engines[$name]->settings['probability'] === 0) {
|
||||||
|
$this->_engines[$name]->gc();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array containing the currently configured Cache settings.
|
* Returns an array containing the currently configured Cache settings.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function configured() {
|
function configured() {
|
||||||
$_this = Cache::getInstance();
|
$self = Cache::getInstance();
|
||||||
return array_keys($_this->__config);
|
return array_keys($self->__config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -141,56 +176,15 @@ class Cache {
|
||||||
* @return boolen success of the removal, returns false when the config does not exist.
|
* @return boolen success of the removal, returns false when the config does not exist.
|
||||||
*/
|
*/
|
||||||
function drop($name) {
|
function drop($name) {
|
||||||
$_this = Cache::getInstance();
|
$self = Cache::getInstance();
|
||||||
if (!isset($_this->__config[$name])) {
|
if (!isset($self->__config[$name])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$last = true;
|
unset($self->__config[$name]);
|
||||||
$engine = $_this->__config[$name]['engine'];
|
unset($self->_engines[$name]);
|
||||||
unset($_this->__config[$name]);
|
|
||||||
foreach ($_this->__config as $name => $settings) {
|
|
||||||
if ($settings['engine'] == $engine) {
|
|
||||||
$last = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($last) {
|
|
||||||
unset($_this->_Engine[$engine]);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the cache engine to use or modify settings for one instance
|
|
||||||
*
|
|
||||||
* @param string $name Name of the engine (without 'Engine')
|
|
||||||
* @param array $settings Optional associative array of settings passed to the engine
|
|
||||||
* @return boolean True on success, false on failure
|
|
||||||
* @access public
|
|
||||||
* @static
|
|
||||||
*/
|
|
||||||
function engine($name = 'File', $settings = array()) {
|
|
||||||
$class = $name;
|
|
||||||
list($plugin, $class) = pluginSplit($name);
|
|
||||||
$cacheClass = $class . 'Engine';
|
|
||||||
$_this =& Cache::getInstance();
|
|
||||||
if (!isset($_this->_Engine[$name])) {
|
|
||||||
if ($_this->__loadEngine($class, $plugin) === false) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$_this->_Engine[$name] =& new $cacheClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_this->_Engine[$name]->init($settings)) {
|
|
||||||
if (time() % $_this->_Engine[$name]->settings['probability'] === 0) {
|
|
||||||
$_this->_Engine[$name]->gc();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
$_this->_Engine[$name] = null;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to find and include a file for a cache engine and returns object instance
|
* Tries to find and include a file for a cache engine and returns object instance
|
||||||
*
|
*
|
||||||
|
@ -200,17 +194,16 @@ class Cache {
|
||||||
*/
|
*/
|
||||||
function __loadEngine($name, $plugin = null) {
|
function __loadEngine($name, $plugin = null) {
|
||||||
if ($plugin) {
|
if ($plugin) {
|
||||||
return App::import('Lib', $plugin . '.cache' . DS . $name);
|
return App::import('Lib', $plugin . '.cache' . DS . $name, false);
|
||||||
} else {
|
} else {
|
||||||
$app = App::import('Lib', 'cache' . DS . $name);
|
$app = App::import('Lib', 'cache' . DS . $name, false);
|
||||||
if (!$app) {
|
if (!$app) {
|
||||||
return App::import('Core', 'cache' . DS . $name);
|
require LIBS . 'cache' . DS . strtolower($name) . '.php';
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Temporarily change settings to current config options. if no params are passed, resets settings if needed
|
* Temporarily change settings to current config options. if no params are passed, resets settings if needed
|
||||||
* Cache::write() will reset the configuration changes made
|
* Cache::write() will reset the configuration changes made
|
||||||
|
@ -222,30 +215,32 @@ class Cache {
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
function set($settings = array(), $value = null) {
|
function set($settings = array(), $value = null) {
|
||||||
$_this =& Cache::getInstance();
|
$self =& Cache::getInstance();
|
||||||
if (!isset($_this->__config[$_this->__name])) {
|
if (!isset($self->__config[$self->__name])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$engine = $_this->__config[$_this->__name]['engine'];
|
$name = $self->__name;
|
||||||
if (!empty($settings)) {
|
if (!empty($settings)) {
|
||||||
$_this->__reset = true;
|
$self->__reset = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_this->__reset === true) {
|
if ($self->__reset === true) {
|
||||||
if (empty($settings)) {
|
if (empty($settings)) {
|
||||||
$_this->__reset = false;
|
$self->__reset = false;
|
||||||
$settings = $_this->__config[$_this->__name];
|
$settings = $self->__config[$name];
|
||||||
} else {
|
} else {
|
||||||
if (is_string($settings) && $value !== null) {
|
if (is_string($settings) && $value !== null) {
|
||||||
$settings = array($settings => $value);
|
$settings = array($settings => $value);
|
||||||
}
|
}
|
||||||
$settings = array_merge($_this->__config[$_this->__name], $settings);
|
$settings = array_merge($self->__config[$self->__name], $settings);
|
||||||
|
if (isset($settings['duration']) && !is_numeric($settings['duration'])) {
|
||||||
|
$settings['duration'] = strtotime($settings['duration']) - time();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$_this->engine($engine, $settings);
|
$self->_engines[$name]->settings = $settings;
|
||||||
}
|
}
|
||||||
|
return $self->settings($name);
|
||||||
return $_this->settings($engine);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -258,9 +253,8 @@ class Cache {
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
function gc() {
|
function gc() {
|
||||||
$_this =& Cache::getInstance();
|
$self =& Cache::getInstance();
|
||||||
$config = $_this->config();
|
$self->_engines[$self->__name]->gc();
|
||||||
$_this->_Engine[$config['engine']]->gc();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -274,37 +268,27 @@ class Cache {
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
function write($key, $value, $config = null) {
|
function write($key, $value, $config = null) {
|
||||||
$_this =& Cache::getInstance();
|
$self =& Cache::getInstance();
|
||||||
|
|
||||||
if ($config && isset($_this->__config[$config])) {
|
if (!$config) {
|
||||||
$settings = $_this->set($_this->__config[$config]);
|
$config = $self->__name;
|
||||||
} else {
|
|
||||||
$settings = $_this->settings();
|
|
||||||
}
|
}
|
||||||
|
$settings = $self->settings($config);
|
||||||
|
|
||||||
if (empty($settings)) {
|
if (empty($settings)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
extract($settings);
|
if (!$self->isInitialized($config)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$key = $self->_engines[$config]->key($key);
|
||||||
|
|
||||||
if (!$_this->isInitialized($engine)) {
|
if (!$key || is_resource($value) || $settings['duration'] < 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$key = $_this->_Engine[$engine]->key($key)) {
|
$success = $self->_engines[$config]->write($settings['prefix'] . $key, $value, $settings['duration']);
|
||||||
return false;
|
$self->set();
|
||||||
}
|
|
||||||
|
|
||||||
if (is_resource($value)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($duration < 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$success = $_this->_Engine[$engine]->write($settings['prefix'] . $key, $value, $duration);
|
|
||||||
$settings = $_this->set();
|
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,29 +302,27 @@ class Cache {
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
function read($key, $config = null) {
|
function read($key, $config = null) {
|
||||||
$_this =& Cache::getInstance();
|
$self =& Cache::getInstance();
|
||||||
|
|
||||||
if (isset($_this->__config[$config])) {
|
if (!$config) {
|
||||||
$settings = $_this->set($_this->__config[$config]);
|
$config = $self->__name;
|
||||||
} else {
|
|
||||||
$settings = $_this->settings();
|
|
||||||
}
|
}
|
||||||
|
$settings = $self->settings($config);
|
||||||
|
|
||||||
if (empty($settings)) {
|
if (empty($settings)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
extract($settings);
|
if (!$self->isInitialized($config)) {
|
||||||
|
|
||||||
if (!$_this->isInitialized($engine)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!$key = $_this->_Engine[$engine]->key($key)) {
|
$key = $self->_engines[$config]->key($key);
|
||||||
|
if (!$key) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$success = $_this->_Engine[$engine]->read($settings['prefix'] . $key);
|
$success = $self->_engines[$config]->read($settings['prefix'] . $key);
|
||||||
|
|
||||||
if ($config !== null && $config !== $_this->__name) {
|
if ($config !== null && $config !== $self->__name) {
|
||||||
$settings = $_this->set();
|
$self->set();
|
||||||
}
|
}
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
@ -355,28 +337,25 @@ class Cache {
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
function delete($key, $config = null) {
|
function delete($key, $config = null) {
|
||||||
$_this =& Cache::getInstance();
|
$self =& Cache::getInstance();
|
||||||
if (isset($_this->__config[$config])) {
|
if (!$config) {
|
||||||
$settings = $_this->set($_this->__config[$config]);
|
$config = $self->__name;
|
||||||
} else {
|
|
||||||
$settings = $_this->settings();
|
|
||||||
}
|
}
|
||||||
|
$settings = $self->settings($config);
|
||||||
|
|
||||||
if (empty($settings)) {
|
if (empty($settings)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
extract($settings);
|
if (!$self->isInitialized($config)) {
|
||||||
|
return false;
|
||||||
if (!$_this->isInitialized($engine)) {
|
}
|
||||||
|
$key = $self->_engines[$config]->key($key);
|
||||||
|
if (!$key) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$key = $_this->_Engine[$engine]->key($key)) {
|
$success = $self->_engines[$config]->delete($settings['prefix'] . $key);
|
||||||
return false;
|
$self->set();
|
||||||
}
|
|
||||||
|
|
||||||
$success = $_this->_Engine[$engine]->delete($settings['prefix'] . $key);
|
|
||||||
$settings = $_this->set();
|
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,28 +369,26 @@ class Cache {
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
function clear($check = false, $config = null) {
|
function clear($check = false, $config = null) {
|
||||||
$_this =& Cache::getInstance();
|
$self =& Cache::getInstance();
|
||||||
if (isset($_this->__config[$config])) {
|
if (!$config) {
|
||||||
$settings = $_this->set($_this->__config[$config]);
|
$config = $self->__name;
|
||||||
} else {
|
|
||||||
$settings = $_this->settings();
|
|
||||||
}
|
}
|
||||||
|
$settings = $self->settings($config);
|
||||||
|
|
||||||
if (empty($settings)) {
|
if (empty($settings)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
extract($settings);
|
|
||||||
|
|
||||||
if (isset($engine) && !$_this->isInitialized($engine)) {
|
if (!$self->isInitialized($config)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$success = $_this->_Engine[$engine]->clear($check);
|
$success = $self->_engines[$config]->clear($check);
|
||||||
$settings = $_this->set();
|
$self->set();
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if Cache has initialized a working storage engine
|
* Check if Cache has initialized a working config for the given name.
|
||||||
*
|
*
|
||||||
* @param string $engine Name of the engine
|
* @param string $engine Name of the engine
|
||||||
* @param string $config Name of the configuration setting
|
* @param string $config Name of the configuration setting
|
||||||
|
@ -419,33 +396,35 @@ class Cache {
|
||||||
* @access public
|
* @access public
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
function isInitialized($engine = null) {
|
function isInitialized($name = null) {
|
||||||
if (Configure::read('Cache.disable')) {
|
if (Configure::read('Cache.disable')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$_this =& Cache::getInstance();
|
$self =& Cache::getInstance();
|
||||||
if (!$engine && isset($_this->__config[$_this->__name]['engine'])) {
|
if (!$name && isset($self->__config[$self->__name])) {
|
||||||
$engine = $_this->__config[$_this->__name]['engine'];
|
$name = $self->__name;
|
||||||
}
|
}
|
||||||
return isset($_this->_Engine[$engine]);
|
return isset($self->_engines[$name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the settings for current cache engine
|
* Return the settings for current cache engine. If no name is supplied the settings
|
||||||
|
* for the 'active default' configuration will be returned. To set the 'active default'
|
||||||
|
* configuration use `Cache::config()`
|
||||||
*
|
*
|
||||||
* @param string $engine Name of the engine
|
* @param string $engine Name of the configuration to get settings for.
|
||||||
* @return array list of settings for this engine
|
* @return array list of settings for this engine
|
||||||
|
* @see Cache::config()
|
||||||
* @access public
|
* @access public
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
function settings($engine = null) {
|
function settings($name = null) {
|
||||||
$_this =& Cache::getInstance();
|
$self =& Cache::getInstance();
|
||||||
if (!$engine && isset($_this->__config[$_this->__name]['engine'])) {
|
if (!$name && isset($self->__config[$self->__name])) {
|
||||||
$engine = $_this->__config[$_this->__name]['engine'];
|
$name = $self->__name;
|
||||||
}
|
}
|
||||||
|
if (!empty($self->_engines[$name])) {
|
||||||
if (isset($_this->_Engine[$engine]) && !is_null($_this->_Engine[$engine])) {
|
return $self->_engines[$name]->settings();
|
||||||
return $_this->_Engine[$engine]->settings();
|
|
||||||
}
|
}
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
11
cake/libs/cache/file.php
vendored
11
cake/libs/cache/file.php
vendored
|
@ -37,11 +37,12 @@ class FileEngine extends CacheEngine {
|
||||||
var $__File = null;
|
var $__File = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* settings
|
* Settings
|
||||||
* path = absolute path to cache directory, default => CACHE
|
*
|
||||||
* prefix = string prefix for filename, default => cake_
|
* - path = absolute path to cache directory, default => CACHE
|
||||||
* lock = enable file locking on write, default => false
|
* - prefix = string prefix for filename, default => cake_
|
||||||
* serialize = serialize the data, default => true
|
* - lock = enable file locking on write, default => false
|
||||||
|
* - serialize = serialize the data, default => true
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @see CacheEngine::__defaults
|
* @see CacheEngine::__defaults
|
||||||
|
|
5
cake/libs/cache/xcache.php
vendored
5
cake/libs/cache/xcache.php
vendored
|
@ -2,7 +2,6 @@
|
||||||
/**
|
/**
|
||||||
* Xcache storage engine for cache.
|
* Xcache storage engine for cache.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* PHP versions 4 and 5
|
* PHP versions 4 and 5
|
||||||
*
|
*
|
||||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||||
|
@ -68,7 +67,7 @@ class XcacheEngine extends CacheEngine {
|
||||||
*/
|
*/
|
||||||
function write($key, &$value, $duration) {
|
function write($key, &$value, $duration) {
|
||||||
$expires = time() + $duration;
|
$expires = time() + $duration;
|
||||||
xcache_set($key.'_expires', $expires, $duration);
|
xcache_set($key . '_expires', $expires, $duration);
|
||||||
return xcache_set($key, $value, $duration);
|
return xcache_set($key, $value, $duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +81,7 @@ class XcacheEngine extends CacheEngine {
|
||||||
function read($key) {
|
function read($key) {
|
||||||
if (xcache_isset($key)) {
|
if (xcache_isset($key)) {
|
||||||
$time = time();
|
$time = time();
|
||||||
$cachetime = intval(xcache_get($key.'_expires'));
|
$cachetime = intval(xcache_get($key . '_expires'));
|
||||||
if ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime) {
|
if ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,11 +212,10 @@ class CakeSession extends Object {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function check($name) {
|
function check($name) {
|
||||||
$var = $this->__validateKeys($name);
|
if (empty($name)) {
|
||||||
if (empty($var)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$result = Set::extract($_SESSION, $var);
|
$result = Set::classicExtract($_SESSION, $name);
|
||||||
return isset($result);
|
return isset($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,13 +258,11 @@ class CakeSession extends Object {
|
||||||
*/
|
*/
|
||||||
function delete($name) {
|
function delete($name) {
|
||||||
if ($this->check($name)) {
|
if ($this->check($name)) {
|
||||||
if ($var = $this->__validateKeys($name)) {
|
if (in_array($name, $this->watchKeys)) {
|
||||||
if (in_array($var, $this->watchKeys)) {
|
trigger_error('Deleting session key {' . $name . '}', E_USER_NOTICE);
|
||||||
trigger_error('Deleting session key {' . $var . '}', E_USER_NOTICE);
|
|
||||||
}
|
|
||||||
$this->__overwrite($_SESSION, Set::remove($_SESSION, $var));
|
|
||||||
return ($this->check($var) == false);
|
|
||||||
}
|
}
|
||||||
|
$this->__overwrite($_SESSION, Set::remove($_SESSION, $name));
|
||||||
|
return ($this->check($name) == false);
|
||||||
}
|
}
|
||||||
$this->__setError(2, "$name doesn't exist");
|
$this->__setError(2, "$name doesn't exist");
|
||||||
return false;
|
return false;
|
||||||
|
@ -354,7 +351,7 @@ class CakeSession extends Object {
|
||||||
if (empty($name)) {
|
if (empty($name)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$result = Set::extract($_SESSION, $name);
|
$result = Set::classicExtract($_SESSION, $name);
|
||||||
|
|
||||||
if (!is_null($result)) {
|
if (!is_null($result)) {
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -385,7 +382,6 @@ class CakeSession extends Object {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function watch($var) {
|
function watch($var) {
|
||||||
$var = $this->__validateKeys($var);
|
|
||||||
if (empty($var)) {
|
if (empty($var)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -402,7 +398,6 @@ class CakeSession extends Object {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function ignore($var) {
|
function ignore($var) {
|
||||||
$var = $this->__validateKeys($var);
|
|
||||||
if (!in_array($var, $this->watchKeys)) {
|
if (!in_array($var, $this->watchKeys)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -424,16 +419,14 @@ class CakeSession extends Object {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function write($name, $value) {
|
function write($name, $value) {
|
||||||
$var = $this->__validateKeys($name);
|
if (empty($name)) {
|
||||||
|
|
||||||
if (empty($var)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (in_array($var, $this->watchKeys)) {
|
if (in_array($name, $this->watchKeys)) {
|
||||||
trigger_error('Writing session key {' . $var . '}: ' . Debugger::exportVar($value), E_USER_NOTICE);
|
trigger_error('Writing session key {' . $name . '}: ' . Debugger::exportVar($value), E_USER_NOTICE);
|
||||||
}
|
}
|
||||||
$this->__overwrite($_SESSION, Set::insert($_SESSION, $var, $value));
|
$this->__overwrite($_SESSION, Set::insert($_SESSION, $name, $value));
|
||||||
return (Set::extract($_SESSION, $var) === $value);
|
return (Set::classicExtract($_SESSION, $name) === $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -676,22 +669,6 @@ class CakeSession extends Object {
|
||||||
$this->__regenerateId();
|
$this->__regenerateId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate that the $name is in correct dot notation
|
|
||||||
* example: $name = 'ControllerName.key';
|
|
||||||
*
|
|
||||||
* @param string $name Session key names as string.
|
|
||||||
* @return mixed false is $name is not correct format, or $name if it is correct
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
function __validateKeys($name) {
|
|
||||||
if (is_string($name) && preg_match("/^[ 0-9a-zA-Z._-]*$/", $name)) {
|
|
||||||
return $name;
|
|
||||||
}
|
|
||||||
$this->__setError(3, "$name is not a string");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to set an internal error message.
|
* Helper method to set an internal error message.
|
||||||
*
|
*
|
||||||
|
|
|
@ -91,11 +91,21 @@ class Configure extends Object {
|
||||||
if (strpos($name, '.') === false) {
|
if (strpos($name, '.') === false) {
|
||||||
$_this->{$name} = $value;
|
$_this->{$name} = $value;
|
||||||
} else {
|
} else {
|
||||||
$names = explode('.', $name, 2);
|
$names = explode('.', $name, 4);
|
||||||
if (!isset($_this->{$names[0]})) {
|
switch (count($names)) {
|
||||||
$_this->{$names[0]} = array();
|
case 2:
|
||||||
|
$_this->{$names[0]}[$names[1]] = $value;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
$_this->{$names[0]}[$names[1]][$names[2]] = $value;
|
||||||
|
case 4:
|
||||||
|
$names = explode('.', $name, 2);
|
||||||
|
if (!isset($_this->{$names[0]})) {
|
||||||
|
$_this->{$names[0]} = array();
|
||||||
|
}
|
||||||
|
$_this->{$names[0]} = Set::insert($_this->{$names[0]}, $names[1], $value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
$_this->{$names[0]} = Set::insert($_this->{$names[0]}, $names[1], $value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,18 +159,32 @@ class Configure extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($var, '.') !== false) {
|
if (strpos($var, '.') !== false) {
|
||||||
$names = explode('.', $var, 2);
|
$names = explode('.', $var, 3);
|
||||||
$var = $names[0];
|
$var = $names[0];
|
||||||
}
|
}
|
||||||
if (!isset($_this->{$var})) {
|
if (!isset($_this->{$var})) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (!isset($names[1])) {
|
||||||
if (!empty($names[1])) {
|
return $_this->{$var};
|
||||||
return Set::extract($_this->{$var}, $names[1]);
|
|
||||||
}
|
}
|
||||||
|
switch (count($names)) {
|
||||||
return $_this->{$var};
|
case 2:
|
||||||
|
if (isset($_this->{$var}[$names[1]])) {
|
||||||
|
return $_this->{$var}[$names[1]];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (isset($_this->{$var}[$names[1]][$names[2]])) {
|
||||||
|
return $_this->{$var}[$names[1]][$names[2]];
|
||||||
|
}
|
||||||
|
if (!isset($_this->{$var}[$names[1]])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Set::classicExtract($_this->{$var}[$names[1]], $names[2]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -528,7 +528,7 @@ class AjaxHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$attr = $this->_parseAttributes(array_merge($options, array('id' => $id)));
|
$attr = $this->_parseAttributes(array_merge($options, array('id' => $id)));
|
||||||
return $this->output(sprintf($this->Html->tags['blockstart'], $attr));
|
return sprintf($this->Html->tags['blockstart'], $attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -547,7 +547,7 @@ class AjaxHelper extends AppHelper {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->output($this->Html->tags['blockend']);
|
return $this->Html->tags['blockend'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -294,7 +294,7 @@ class FormHelper extends AppHelper {
|
||||||
|
|
||||||
$this->setEntity($model . '.', true);
|
$this->setEntity($model . '.', true);
|
||||||
$attributes = $this->_parseAttributes($htmlAttributes, null, '');
|
$attributes = $this->_parseAttributes($htmlAttributes, null, '');
|
||||||
return $this->output(sprintf($this->Html->tags['form'], $attributes)) . $append;
|
return sprintf($this->Html->tags['form'], $attributes) . $append;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -349,7 +349,7 @@ class FormHelper extends AppHelper {
|
||||||
|
|
||||||
$view =& ClassRegistry::getObject('view');
|
$view =& ClassRegistry::getObject('view');
|
||||||
$view->modelScope = false;
|
$view->modelScope = false;
|
||||||
return $this->output($out);
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -528,11 +528,11 @@ class FormHelper extends AppHelper {
|
||||||
$labelFor = $this->domId($fieldName);
|
$labelFor = $this->domId($fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->output(sprintf(
|
return sprintf(
|
||||||
$this->Html->tags['label'],
|
$this->Html->tags['label'],
|
||||||
$labelFor,
|
$labelFor,
|
||||||
$this->_parseAttributes($options), $text
|
$this->_parseAttributes($options), $text
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -940,11 +940,11 @@ class FormHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
unset($options['hiddenField']);
|
unset($options['hiddenField']);
|
||||||
|
|
||||||
return $this->output($output . sprintf(
|
return $output . sprintf(
|
||||||
$this->Html->tags['checkbox'],
|
$this->Html->tags['checkbox'],
|
||||||
$options['name'],
|
$options['name'],
|
||||||
$this->_parseAttributes($options, array('name'), null, ' ')
|
$this->_parseAttributes($options, array('name'), null, ' ')
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1036,7 +1036,7 @@ class FormHelper extends AppHelper {
|
||||||
sprintf($this->Html->tags['legend'], $legend) . $out
|
sprintf($this->Html->tags['legend'], $legend) . $out
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $this->output($out);
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1050,11 +1050,11 @@ class FormHelper extends AppHelper {
|
||||||
$options = $this->_initInputField($fieldName, array_merge(
|
$options = $this->_initInputField($fieldName, array_merge(
|
||||||
array('type' => 'text'), $options
|
array('type' => 'text'), $options
|
||||||
));
|
));
|
||||||
return $this->output(sprintf(
|
return sprintf(
|
||||||
$this->Html->tags['input'],
|
$this->Html->tags['input'],
|
||||||
$options['name'],
|
$options['name'],
|
||||||
$this->_parseAttributes($options, array('name'), null, ' ')
|
$this->_parseAttributes($options, array('name'), null, ' ')
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1066,11 +1066,11 @@ class FormHelper extends AppHelper {
|
||||||
*/
|
*/
|
||||||
function password($fieldName, $options = array()) {
|
function password($fieldName, $options = array()) {
|
||||||
$options = $this->_initInputField($fieldName, $options);
|
$options = $this->_initInputField($fieldName, $options);
|
||||||
return $this->output(sprintf(
|
return sprintf(
|
||||||
$this->Html->tags['password'],
|
$this->Html->tags['password'],
|
||||||
$options['name'],
|
$options['name'],
|
||||||
$this->_parseAttributes($options, array('name'), null, ' ')
|
$this->_parseAttributes($options, array('name'), null, ' ')
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1091,12 +1091,12 @@ class FormHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
unset($options['value']);
|
unset($options['value']);
|
||||||
}
|
}
|
||||||
return $this->output(sprintf(
|
return sprintf(
|
||||||
$this->Html->tags['textarea'],
|
$this->Html->tags['textarea'],
|
||||||
$options['name'],
|
$options['name'],
|
||||||
$this->_parseAttributes($options, array('type', 'name'), null, ' '),
|
$this->_parseAttributes($options, array('type', 'name'), null, ' '),
|
||||||
$value
|
$value
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1123,11 +1123,11 @@ class FormHelper extends AppHelper {
|
||||||
$this->__secure(null, '' . $options['value']);
|
$this->__secure(null, '' . $options['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->output(sprintf(
|
return sprintf(
|
||||||
$this->Html->tags['hidden'],
|
$this->Html->tags['hidden'],
|
||||||
$options['name'],
|
$options['name'],
|
||||||
$this->_parseAttributes($options, array('name', 'class'), '', ' ')
|
$this->_parseAttributes($options, array('name', 'class'), '', ' ')
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1149,7 +1149,7 @@ class FormHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
$attributes = $this->_parseAttributes($options, array('name'), '', ' ');
|
$attributes = $this->_parseAttributes($options, array('name'), '', ' ');
|
||||||
return $this->output(sprintf($this->Html->tags['file'], $options['name'], $attributes));
|
return sprintf($this->Html->tags['file'], $options['name'], $attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1169,12 +1169,12 @@ class FormHelper extends AppHelper {
|
||||||
if ($options['escape']) {
|
if ($options['escape']) {
|
||||||
$title = h($title);
|
$title = h($title);
|
||||||
}
|
}
|
||||||
return $this->output(sprintf(
|
return sprintf(
|
||||||
$this->Html->tags['button'],
|
$this->Html->tags['button'],
|
||||||
$options['type'],
|
$options['type'],
|
||||||
$this->_parseAttributes($options, array('type'), '', ' '),
|
$this->_parseAttributes($options, array('type'), '', ' '),
|
||||||
$title
|
$title
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1217,11 +1217,11 @@ class FormHelper extends AppHelper {
|
||||||
|
|
||||||
if (strpos($caption, '://') !== false) {
|
if (strpos($caption, '://') !== false) {
|
||||||
unset($options['type']);
|
unset($options['type']);
|
||||||
$out .= $this->output($before . sprintf(
|
$out .= $before . sprintf(
|
||||||
$this->Html->tags['submitimage'],
|
$this->Html->tags['submitimage'],
|
||||||
$caption,
|
$caption,
|
||||||
$this->_parseAttributes($options, null, '', ' ')
|
$this->_parseAttributes($options, null, '', ' ')
|
||||||
) . $after);
|
) . $after;
|
||||||
} elseif (preg_match('/\.(jpg|jpe|jpeg|gif|png|ico)$/', $caption)) {
|
} elseif (preg_match('/\.(jpg|jpe|jpeg|gif|png|ico)$/', $caption)) {
|
||||||
unset($options['type']);
|
unset($options['type']);
|
||||||
if ($caption{0} !== '/') {
|
if ($caption{0} !== '/') {
|
||||||
|
@ -1230,17 +1230,17 @@ class FormHelper extends AppHelper {
|
||||||
$caption = trim($caption, '/');
|
$caption = trim($caption, '/');
|
||||||
$url = $this->webroot($caption);
|
$url = $this->webroot($caption);
|
||||||
}
|
}
|
||||||
$out .= $this->output($before . sprintf(
|
$out .= $before . sprintf(
|
||||||
$this->Html->tags['submitimage'],
|
$this->Html->tags['submitimage'],
|
||||||
$url,
|
$url,
|
||||||
$this->_parseAttributes($options, null, '', ' ')
|
$this->_parseAttributes($options, null, '', ' ')
|
||||||
) . $after);
|
) . $after;
|
||||||
} else {
|
} else {
|
||||||
$options['value'] = $caption;
|
$options['value'] = $caption;
|
||||||
$out .= $this->output($before . sprintf(
|
$out .= $before . sprintf(
|
||||||
$this->Html->tags['submit'],
|
$this->Html->tags['submit'],
|
||||||
$this->_parseAttributes($options, null, '', ' ')
|
$this->_parseAttributes($options, null, '', ' ')
|
||||||
). $after);
|
). $after;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($divOptions)) {
|
if (isset($divOptions)) {
|
||||||
|
@ -1347,7 +1347,7 @@ class FormHelper extends AppHelper {
|
||||||
|
|
||||||
$template = ($style == 'checkbox') ? 'checkboxmultipleend' : 'selectend';
|
$template = ($style == 'checkbox') ? 'checkboxmultipleend' : 'selectend';
|
||||||
$select[] = $this->Html->tags[$template];
|
$select[] = $this->Html->tags[$template];
|
||||||
return $this->output(implode("\n", $select));
|
return implode("\n", $select);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -201,7 +201,7 @@ class HtmlHelper extends AppHelper {
|
||||||
*/
|
*/
|
||||||
function docType($type = 'xhtml-strict') {
|
function docType($type = 'xhtml-strict') {
|
||||||
if (isset($this->__docTypes[$type])) {
|
if (isset($this->__docTypes[$type])) {
|
||||||
return $this->output($this->__docTypes[$type]);
|
return $this->__docTypes[$type];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ class HtmlHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($inline) {
|
if ($inline) {
|
||||||
return $this->output($out);
|
return $out;
|
||||||
} else {
|
} else {
|
||||||
$view =& ClassRegistry::getObject('view');
|
$view =& ClassRegistry::getObject('view');
|
||||||
$view->addScript($out);
|
$view->addScript($out);
|
||||||
|
@ -288,7 +288,7 @@ class HtmlHelper extends AppHelper {
|
||||||
if (empty($charset)) {
|
if (empty($charset)) {
|
||||||
$charset = strtolower(Configure::read('App.encoding'));
|
$charset = strtolower(Configure::read('App.encoding'));
|
||||||
}
|
}
|
||||||
return $this->output(sprintf($this->tags['charset'], (!empty($charset) ? $charset : 'utf-8')));
|
return sprintf($this->tags['charset'], (!empty($charset) ? $charset : 'utf-8'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -347,7 +347,7 @@ class HtmlHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
unset($options['default']);
|
unset($options['default']);
|
||||||
}
|
}
|
||||||
return $this->output(sprintf($this->tags['link'], $url, $this->_parseAttributes($options), $title));
|
return sprintf($this->tags['link'], $url, $this->_parseAttributes($options), $title);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -408,7 +408,6 @@ class HtmlHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
$out = sprintf($this->tags['css'], $rel, $url, $this->_parseAttributes($options, array('inline'), '', ' '));
|
$out = sprintf($this->tags['css'], $rel, $url, $this->_parseAttributes($options, array('inline'), '', ' '));
|
||||||
}
|
}
|
||||||
$out = $this->output($out);
|
|
||||||
|
|
||||||
if ($options['inline']) {
|
if ($options['inline']) {
|
||||||
return $out;
|
return $out;
|
||||||
|
@ -472,7 +471,7 @@ class HtmlHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$attributes = $this->_parseAttributes($options, array('inline', 'once'), ' ');
|
$attributes = $this->_parseAttributes($options, array('inline', 'once'), ' ');
|
||||||
$out = $this->output(sprintf($this->tags['javascriptlink'], $url, $attributes));
|
$out = sprintf($this->tags['javascriptlink'], $url, $attributes);
|
||||||
|
|
||||||
if ($options['inline']) {
|
if ($options['inline']) {
|
||||||
return $out;
|
return $out;
|
||||||
|
@ -585,7 +584,7 @@ class HtmlHelper extends AppHelper {
|
||||||
$out[] = $crumb[0];
|
$out[] = $crumb[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->output(implode($separator, $out));
|
return join($separator, $out);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -624,9 +623,9 @@ class HtmlHelper extends AppHelper {
|
||||||
$image = sprintf($this->tags['image'], $path, $this->_parseAttributes($options, null, '', ' '));
|
$image = sprintf($this->tags['image'], $path, $this->_parseAttributes($options, null, '', ' '));
|
||||||
|
|
||||||
if ($url) {
|
if ($url) {
|
||||||
return $this->output(sprintf($this->tags['link'], $this->url($url), null, $image));
|
return sprintf($this->tags['link'], $this->url($url), null, $image);
|
||||||
}
|
}
|
||||||
return $this->output($image);
|
return $image;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -643,8 +642,7 @@ class HtmlHelper extends AppHelper {
|
||||||
foreach ($names as $arg) {
|
foreach ($names as $arg) {
|
||||||
$out[] = sprintf($this->tags['tableheader'], $this->_parseAttributes($thOptions), $arg);
|
$out[] = sprintf($this->tags['tableheader'], $this->_parseAttributes($thOptions), $arg);
|
||||||
}
|
}
|
||||||
$data = sprintf($this->tags['tablerow'], $this->_parseAttributes($trOptions), implode(' ', $out));
|
return sprintf($this->tags['tablerow'], $this->_parseAttributes($trOptions), join(' ', $out));
|
||||||
return $this->output($data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -698,7 +696,7 @@ class HtmlHelper extends AppHelper {
|
||||||
$options = $this->_parseAttributes($count % 2 ? $oddTrOptions : $evenTrOptions);
|
$options = $this->_parseAttributes($count % 2 ? $oddTrOptions : $evenTrOptions);
|
||||||
$out[] = sprintf($this->tags['tablerow'], $options, implode(' ', $cellsOut));
|
$out[] = sprintf($this->tags['tablerow'], $options, implode(' ', $cellsOut));
|
||||||
}
|
}
|
||||||
return $this->output(implode("\n", $out));
|
return implode("\n", $out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -729,7 +727,7 @@ class HtmlHelper extends AppHelper {
|
||||||
} else {
|
} else {
|
||||||
$tag = 'tag';
|
$tag = 'tag';
|
||||||
}
|
}
|
||||||
return $this->output(sprintf($this->tags[$tag], $name, $this->_parseAttributes($options, null, ' ', ''), $text, $name));
|
return sprintf($this->tags[$tag], $name, $this->_parseAttributes($options, null, ' ', ''), $text, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -778,7 +776,7 @@ class HtmlHelper extends AppHelper {
|
||||||
} else {
|
} else {
|
||||||
$tag = 'para';
|
$tag = 'para';
|
||||||
}
|
}
|
||||||
return $this->output(sprintf($this->tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $text));
|
return sprintf($this->tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -273,7 +273,7 @@ class JavascriptHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$out = $this->output(sprintf($this->tags['javascriptlink'], $url));
|
$out = sprintf($this->tags['javascriptlink'], $url);
|
||||||
|
|
||||||
if ($inline) {
|
if ($inline) {
|
||||||
return $out;
|
return $out;
|
||||||
|
|
|
@ -555,7 +555,7 @@ class PaginatorHelper extends AppHelper {
|
||||||
$out = str_replace($newKeys, array_values($map), $out);
|
$out = str_replace($newKeys, array_values($map), $out);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $this->output($out);
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -676,7 +676,7 @@ class PaginatorHelper extends AppHelper {
|
||||||
$out .= $after;
|
$out .= $after;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->output($out);
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -269,7 +269,7 @@ class RssHelper extends XmlHelper {
|
||||||
if (!empty($elements)) {
|
if (!empty($elements)) {
|
||||||
$content = implode('', $elements);
|
$content = implode('', $elements);
|
||||||
}
|
}
|
||||||
return $this->output($this->elem('item', $att, $content, !($content === null)));
|
return $this->elem('item', $att, $content, !($content === null));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -87,8 +87,7 @@ class TimeHelper extends AppHelper {
|
||||||
$date = time();
|
$date = time();
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = date("D, M jS Y, H:i", $date);
|
return date("D, M jS Y, H:i", $date);
|
||||||
return $this->output($ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,8 +114,7 @@ class TimeHelper extends AppHelper {
|
||||||
} else {
|
} else {
|
||||||
$ret = date("M jS{$y}, H:i", $date);
|
$ret = date("M jS{$y}, H:i", $date);
|
||||||
}
|
}
|
||||||
|
return $ret;
|
||||||
return $this->output($ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,8 +132,7 @@ class TimeHelper extends AppHelper {
|
||||||
$begin = date('Y-m-d', $begin) . ' 00:00:00';
|
$begin = date('Y-m-d', $begin) . ' 00:00:00';
|
||||||
$end = date('Y-m-d', $end) . ' 23:59:59';
|
$end = date('Y-m-d', $end) . ' 23:59:59';
|
||||||
|
|
||||||
$ret ="($fieldName >= '$begin') AND ($fieldName <= '$end')";
|
return "($fieldName >= '$begin') AND ($fieldName <= '$end')";
|
||||||
return $this->output($ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,8 +146,7 @@ class TimeHelper extends AppHelper {
|
||||||
*/
|
*/
|
||||||
function dayAsSql($dateString, $fieldName, $userOffset = null) {
|
function dayAsSql($dateString, $fieldName, $userOffset = null) {
|
||||||
$date = $this->fromString($dateString, $userOffset);
|
$date = $this->fromString($dateString, $userOffset);
|
||||||
$ret = $this->daysAsSql($dateString, $dateString, $fieldName);
|
return $this->daysAsSql($dateString, $dateString, $fieldName);
|
||||||
return $this->output($ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -254,7 +250,7 @@ class TimeHelper extends AppHelper {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->output($date);
|
return $date;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -265,8 +261,7 @@ class TimeHelper extends AppHelper {
|
||||||
* @return integer Unix timestamp
|
* @return integer Unix timestamp
|
||||||
*/
|
*/
|
||||||
function toUnix($dateString, $userOffset = null) {
|
function toUnix($dateString, $userOffset = null) {
|
||||||
$ret = $this->fromString($dateString, $userOffset);
|
return $this->fromString($dateString, $userOffset);
|
||||||
return $this->output($ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -278,8 +273,7 @@ class TimeHelper extends AppHelper {
|
||||||
*/
|
*/
|
||||||
function toAtom($dateString, $userOffset = null) {
|
function toAtom($dateString, $userOffset = null) {
|
||||||
$date = $this->fromString($dateString, $userOffset);
|
$date = $this->fromString($dateString, $userOffset);
|
||||||
$ret = date('Y-m-d\TH:i:s\Z', $date);
|
return date('Y-m-d\TH:i:s\Z', $date);
|
||||||
return $this->output($ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -291,8 +285,7 @@ class TimeHelper extends AppHelper {
|
||||||
*/
|
*/
|
||||||
function toRSS($dateString, $userOffset = null) {
|
function toRSS($dateString, $userOffset = null) {
|
||||||
$date = $this->fromString($dateString, $userOffset);
|
$date = $this->fromString($dateString, $userOffset);
|
||||||
$ret = date("r", $date);
|
return date("r", $date);
|
||||||
return $this->output($ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -472,7 +465,7 @@ class TimeHelper extends AppHelper {
|
||||||
$relativeDate = sprintf(__('%s ago', true), $relativeDate);
|
$relativeDate = sprintf(__('%s ago', true), $relativeDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->output($relativeDate);
|
return $relativeDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -65,7 +65,7 @@ class XmlHelper extends AppHelper {
|
||||||
$attrib = 'xml ' . $attrib;
|
$attrib = 'xml ' . $attrib;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->output($this->Xml->header($attrib));
|
return $this->Xml->header($attrib);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,7 +131,7 @@ class XmlHelper extends AppHelper {
|
||||||
if (!$endTag) {
|
if (!$endTag) {
|
||||||
$this->Xml =& $elem;
|
$this->Xml =& $elem;
|
||||||
}
|
}
|
||||||
return $this->output($out);
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -144,7 +144,7 @@ class XmlHelper extends AppHelper {
|
||||||
if ($parent =& $this->Xml->parent()) {
|
if ($parent =& $this->Xml->parent()) {
|
||||||
$this->Xml =& $parent;
|
$this->Xml =& $parent;
|
||||||
}
|
}
|
||||||
return $this->output('</' . $name . '>');
|
return '</' . $name . '>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -115,6 +115,51 @@ class ProjectTaskTest extends CakeTestCase {
|
||||||
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'fixtures'), 'No fixtures dir %s');
|
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'fixtures'), 'No fixtures dir %s');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test bake() method with -empty flag, directory creation and empty files.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function testBakeEmptyFlag() {
|
||||||
|
$this->Task->params['empty'] = true;
|
||||||
|
$this->_setupTestProject();
|
||||||
|
$path = $this->Task->path . 'bake_test_app';
|
||||||
|
$this->assertTrue(is_dir($path), 'No project dir %s');
|
||||||
|
$this->assertTrue(is_dir($path . DS . 'controllers'), 'No controllers dir %s');
|
||||||
|
$this->assertTrue(is_dir($path . DS . 'controllers' . DS .'components'), 'No components dir %s');
|
||||||
|
$this->assertTrue(is_dir($path . DS . 'models'), 'No models dir %s');
|
||||||
|
$this->assertTrue(is_dir($path . DS . 'views'), 'No views dir %s');
|
||||||
|
$this->assertTrue(is_dir($path . DS . 'views' . DS . 'helpers'), 'No helpers dir %s');
|
||||||
|
$this->assertTrue(is_dir($path . DS . 'tests'), 'No tests dir %s');
|
||||||
|
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'cases'), 'No cases dir %s');
|
||||||
|
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'groups'), 'No groups dir %s');
|
||||||
|
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'fixtures'), 'No fixtures dir %s');
|
||||||
|
|
||||||
|
$this->assertTrue(is_file($path . DS . 'controllers' . DS .'components' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
$this->assertTrue(is_file($path . DS . 'locale' . DS . 'eng' . DS . 'LC_MESSAGES' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
$this->assertTrue(is_file($path . DS . 'models' . DS . 'behaviors' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
$this->assertTrue(is_file($path . DS . 'models' . DS . 'datasources' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
$this->assertTrue(is_file($path . DS . 'plugins' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'behaviors' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'components' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'controllers' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'datasources' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'helpers' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'models' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'shells' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'fixtures' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'groups' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
$this->assertTrue(is_file($path . DS . 'vendors' . DS . 'css' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
$this->assertTrue(is_file($path . DS . 'vendors' . DS . 'img' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
$this->assertTrue(is_file($path . DS . 'vendors' . DS . 'js' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
$this->assertTrue(is_file($path . DS . 'vendors' . DS . 'shells' . DS . 'tasks' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
$this->assertTrue(is_file($path . DS . 'views' . DS . 'errors' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
$this->assertTrue(is_file($path . DS . 'views' . DS . 'helpers' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
$this->assertTrue(is_file($path . DS . 'views' . DS . 'scaffolds' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
$this->assertTrue(is_file($path . DS . 'webroot' . DS . 'js' . DS . 'empty'), 'No empty file in dir %s');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test generation of Security.salt
|
* test generation of Security.salt
|
||||||
*
|
*
|
||||||
|
@ -141,7 +186,7 @@ class ProjectTaskTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function testIndexPhpGeneration() {
|
function testIndexPhpGeneration() {
|
||||||
$this->_setupTestProject();
|
$this->_setupTestProject();
|
||||||
|
|
||||||
$path = $this->Task->path . 'bake_test_app' . DS;
|
$path = $this->Task->path . 'bake_test_app' . DS;
|
||||||
$this->Task->corePath($path);
|
$this->Task->corePath($path);
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,6 @@ class CacheTest extends CakeTestCase {
|
||||||
|
|
||||||
$this->_defaultCacheConfig = Cache::config('default');
|
$this->_defaultCacheConfig = Cache::config('default');
|
||||||
Cache::config('default', array('engine' => 'File', 'path' => TMP . 'tests'));
|
Cache::config('default', array('engine' => 'File', 'path' => TMP . 'tests'));
|
||||||
|
|
||||||
Cache::engine('File', array('path' => TMP . 'tests'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +54,6 @@ class CacheTest extends CakeTestCase {
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
Configure::write('Cache.disable', $this->_cacheDisable);
|
Configure::write('Cache.disable', $this->_cacheDisable);
|
||||||
Cache::config('default', $this->_defaultCacheConfig['settings']);
|
Cache::config('default', $this->_defaultCacheConfig['settings']);
|
||||||
Cache::engine('File');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,15 +124,45 @@ class CacheTest extends CakeTestCase {
|
||||||
$_cacheConfigTests = Cache::config('tests');
|
$_cacheConfigTests = Cache::config('tests');
|
||||||
|
|
||||||
$result = Cache::config('sessions', array('engine'=> 'File', 'path' => TMP . 'sessions'));
|
$result = Cache::config('sessions', array('engine'=> 'File', 'path' => TMP . 'sessions'));
|
||||||
$this->assertEqual($result['settings'], Cache::settings('File'));
|
$this->assertEqual($result['settings'], Cache::settings('sessions'));
|
||||||
|
|
||||||
$result = Cache::config('tests', array('engine'=> 'File', 'path' => TMP . 'tests'));
|
$result = Cache::config('tests', array('engine'=> 'File', 'path' => TMP . 'tests'));
|
||||||
$this->assertEqual($result['settings'], Cache::settings('File'));
|
$this->assertEqual($result['settings'], Cache::settings('tests'));
|
||||||
|
|
||||||
Cache::config('sessions', $_cacheConfigSessions['settings']);
|
Cache::config('sessions', $_cacheConfigSessions['settings']);
|
||||||
Cache::config('tests', $_cacheConfigTests['settings']);
|
Cache::config('tests', $_cacheConfigTests['settings']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test that calling config() sets the 'default' configuration up.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testConfigSettingDefaultConfigKey() {
|
||||||
|
Cache::config('test_name', array('engine' => 'File', 'prefix' => 'test_name_'));
|
||||||
|
|
||||||
|
Cache::config('test_name');
|
||||||
|
Cache::write('value_one', 'I am cached');
|
||||||
|
$result = Cache::read('value_one');
|
||||||
|
$this->assertEqual($result, 'I am cached');
|
||||||
|
|
||||||
|
Cache::config('default');
|
||||||
|
$result = Cache::read('value_one');
|
||||||
|
$this->assertEqual($result, null);
|
||||||
|
|
||||||
|
Cache::write('value_one', 'I am in another cache config!');
|
||||||
|
$result = Cache::read('value_one');
|
||||||
|
$this->assertEqual($result, 'I am in another cache config!');
|
||||||
|
|
||||||
|
Cache::config('test_name');
|
||||||
|
$result = Cache::read('value_one');
|
||||||
|
$this->assertEqual($result, 'I am cached');
|
||||||
|
|
||||||
|
Cache::delete('value_one');
|
||||||
|
Cache::config('default');
|
||||||
|
Cache::delete('value_one');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testWritingWithConfig method
|
* testWritingWithConfig method
|
||||||
*
|
*
|
||||||
|
@ -157,7 +184,7 @@ class CacheTest extends CakeTestCase {
|
||||||
'engine' => 'File',
|
'engine' => 'File',
|
||||||
'isWindows' => DIRECTORY_SEPARATOR == '\\'
|
'isWindows' => DIRECTORY_SEPARATOR == '\\'
|
||||||
);
|
);
|
||||||
$this->assertEqual($expected, Cache::settings('File'));
|
$this->assertEqual($expected, Cache::settings('sessions'));
|
||||||
|
|
||||||
Cache::config('sessions', $_cacheConfigSessions['settings']);
|
Cache::config('sessions', $_cacheConfigSessions['settings']);
|
||||||
}
|
}
|
||||||
|
@ -181,7 +208,7 @@ class CacheTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testInitSettings() {
|
function testInitSettings() {
|
||||||
Cache::engine('File', array('path' => TMP . 'tests'));
|
Cache::config('default', array('engine' => 'File', 'path' => TMP . 'tests'));
|
||||||
|
|
||||||
$settings = Cache::settings();
|
$settings = Cache::settings();
|
||||||
$expecting = array(
|
$expecting = array(
|
||||||
|
@ -195,17 +222,15 @@ class CacheTest extends CakeTestCase {
|
||||||
'isWindows' => DIRECTORY_SEPARATOR == '\\'
|
'isWindows' => DIRECTORY_SEPARATOR == '\\'
|
||||||
);
|
);
|
||||||
$this->assertEqual($settings, $expecting);
|
$this->assertEqual($settings, $expecting);
|
||||||
|
|
||||||
Cache::engine('File');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test that unconfig removes cache configs, and that further attempts to use that config
|
* test that drop removes cache configs, and that further attempts to use that config
|
||||||
* do not work.
|
* do not work.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testUnconfig() {
|
function testDrop() {
|
||||||
App::build(array(
|
App::build(array(
|
||||||
'libs' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
|
'libs' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
|
||||||
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
||||||
|
@ -221,7 +246,7 @@ class CacheTest extends CakeTestCase {
|
||||||
Cache::config('unconfigTest', array(
|
Cache::config('unconfigTest', array(
|
||||||
'engine' => 'TestAppCache'
|
'engine' => 'TestAppCache'
|
||||||
));
|
));
|
||||||
$this->assertTrue(Cache::isInitialized('TestAppCache'));
|
$this->assertTrue(Cache::isInitialized('unconfigTest'));
|
||||||
|
|
||||||
$this->assertTrue(Cache::drop('unconfigTest'));
|
$this->assertTrue(Cache::drop('unconfigTest'));
|
||||||
$this->assertFalse(Cache::isInitialized('TestAppCache'));
|
$this->assertFalse(Cache::isInitialized('TestAppCache'));
|
||||||
|
@ -324,5 +349,6 @@ class CacheTest extends CakeTestCase {
|
||||||
|
|
||||||
Cache::set($_cacheSet);
|
Cache::set($_cacheSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
5
cake/tests/cases/libs/cache/apc.test.php
vendored
5
cake/tests/cases/libs/cache/apc.test.php
vendored
|
@ -39,7 +39,7 @@ class ApcEngineTest extends UnitTestCase {
|
||||||
*/
|
*/
|
||||||
function skip() {
|
function skip() {
|
||||||
$skip = true;
|
$skip = true;
|
||||||
if (Cache::engine('Apc')) {
|
if (function_exists('apc_store')) {
|
||||||
$skip = false;
|
$skip = false;
|
||||||
}
|
}
|
||||||
$this->skipIf($skip, '%s Apc is not installed or configured properly');
|
$this->skipIf($skip, '%s Apc is not installed or configured properly');
|
||||||
|
@ -65,6 +65,7 @@ class ApcEngineTest extends UnitTestCase {
|
||||||
*/
|
*/
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
Configure::write('Cache.disable', $this->_cacheDisable);
|
Configure::write('Cache.disable', $this->_cacheDisable);
|
||||||
|
Cache::drop('apc');
|
||||||
Cache::config('default');
|
Cache::config('default');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +113,7 @@ class ApcEngineTest extends UnitTestCase {
|
||||||
$result = Cache::read('other_test');
|
$result = Cache::read('other_test');
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
|
|
||||||
Cache::set(array('duration' => "+1 second"));
|
Cache::set(array('duration' => 1));
|
||||||
|
|
||||||
$data = 'this is a test of the emergency broadcasting system';
|
$data = 'this is a test of the emergency broadcasting system';
|
||||||
$result = Cache::write('other_test', $data);
|
$result = Cache::write('other_test', $data);
|
||||||
|
|
95
cake/tests/cases/libs/cache/file.test.php
vendored
95
cake/tests/cases/libs/cache/file.test.php
vendored
|
@ -2,8 +2,6 @@
|
||||||
/**
|
/**
|
||||||
* FileEngineTest file
|
* FileEngineTest file
|
||||||
*
|
*
|
||||||
* Long description for file
|
|
||||||
*
|
|
||||||
* PHP versions 4 and 5
|
* PHP versions 4 and 5
|
||||||
*
|
*
|
||||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||||
|
@ -22,9 +20,6 @@
|
||||||
if (!class_exists('Cache')) {
|
if (!class_exists('Cache')) {
|
||||||
require LIBS . 'cache.php';
|
require LIBS . 'cache.php';
|
||||||
}
|
}
|
||||||
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
|
||||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FileEngineTest class
|
* FileEngineTest class
|
||||||
|
@ -74,12 +69,11 @@ class FileEngineTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function testCacheDirChange() {
|
function testCacheDirChange() {
|
||||||
$result = Cache::config('sessions', array('engine'=> 'File', 'path' => TMP . 'sessions'));
|
$result = Cache::config('sessions', array('engine'=> 'File', 'path' => TMP . 'sessions'));
|
||||||
$this->assertEqual($result['settings'], Cache::settings('File'));
|
$this->assertEqual($result['settings'], Cache::settings('sessions'));
|
||||||
$this->assertNotEqual($result, Cache::settings('File'));
|
|
||||||
|
|
||||||
$result = Cache::config('tests', array('engine'=> 'File', 'path' => TMP . 'tests'));
|
$result = Cache::config('sessions', array('engine'=> 'File', 'path' => TMP . 'tests'));
|
||||||
$this->assertEqual($result['settings'], Cache::settings('File'));
|
$this->assertEqual($result['settings'], Cache::settings('sessions'));
|
||||||
$this->assertNotEqual($result, Cache::settings('File'));
|
$this->assertNotEqual($result['settings'], Cache::settings('default'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -159,7 +153,6 @@ class FileEngineTest extends CakeTestCase {
|
||||||
|
|
||||||
$result = Cache::delete('delete_test');
|
$result = Cache::delete('delete_test');
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -169,12 +162,12 @@ class FileEngineTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testSerialize() {
|
function testSerialize() {
|
||||||
Cache::engine('File', array('serialize' => true));
|
Cache::config('default', array('engine' => 'File', 'serialize' => true));
|
||||||
$data = 'this is a test of the emergency broadcasting system';
|
$data = 'this is a test of the emergency broadcasting system';
|
||||||
$write = Cache::write('serialize_test', $data, 1);
|
$write = Cache::write('serialize_test', $data);
|
||||||
$this->assertTrue($write);
|
$this->assertTrue($write);
|
||||||
|
|
||||||
Cache::engine('File', array('serialize' => false));
|
Cache::config('default', array('serialize' => false));
|
||||||
$read = Cache::read('serialize_test');
|
$read = Cache::read('serialize_test');
|
||||||
|
|
||||||
$newread = Cache::read('serialize_test');
|
$newread = Cache::read('serialize_test');
|
||||||
|
@ -184,7 +177,6 @@ class FileEngineTest extends CakeTestCase {
|
||||||
$this->assertIdentical($read, serialize($data));
|
$this->assertIdentical($read, serialize($data));
|
||||||
|
|
||||||
$this->assertIdentical(unserialize($newread), $data);
|
$this->assertIdentical(unserialize($newread), $data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -194,7 +186,7 @@ class FileEngineTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testClear() {
|
function testClear() {
|
||||||
Cache::engine('File', array('duration' => 1));
|
Cache::config('default', array('engine' => 'File', 'duration' => 1));
|
||||||
$data = 'this is a test of the emergency broadcasting system';
|
$data = 'this is a test of the emergency broadcasting system';
|
||||||
$write = Cache::write('serialize_test1', $data);
|
$write = Cache::write('serialize_test1', $data);
|
||||||
$write = Cache::write('serialize_test2', $data);
|
$write = Cache::write('serialize_test2', $data);
|
||||||
|
@ -223,7 +215,7 @@ class FileEngineTest extends CakeTestCase {
|
||||||
$this->assertFalse(file_exists(CACHE . 'cake_serialize_test2'));
|
$this->assertFalse(file_exists(CACHE . 'cake_serialize_test2'));
|
||||||
$this->assertFalse(file_exists(CACHE . 'cake_serialize_test3'));
|
$this->assertFalse(file_exists(CACHE . 'cake_serialize_test3'));
|
||||||
|
|
||||||
$result = Cache::engine('File', array('path' => CACHE . 'views'));
|
Cache::config('default', array('engine' => 'File', 'path' => CACHE . 'views'));
|
||||||
|
|
||||||
$data = 'this is a test of the emergency broadcasting system';
|
$data = 'this is a test of the emergency broadcasting system';
|
||||||
$write = Cache::write('controller_view_1', $data);
|
$write = Cache::write('controller_view_1', $data);
|
||||||
|
@ -278,7 +270,7 @@ class FileEngineTest extends CakeTestCase {
|
||||||
|
|
||||||
clearCache('controller_view');
|
clearCache('controller_view');
|
||||||
|
|
||||||
Cache::engine('File', array('path' => CACHE));
|
Cache::config('default', array('engine' => 'File', 'path' => CACHE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -306,40 +298,43 @@ class FileEngineTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testRemoveWindowsSlashesFromCache() {
|
function testRemoveWindowsSlashesFromCache() {
|
||||||
Cache::engine('File', array('isWindows' => true, 'prefix' => null, 'path' => TMP));
|
Cache::config('windows_test', array('engine' => 'File', 'isWindows' => true, 'prefix' => null, 'path' => TMP));
|
||||||
|
|
||||||
$expected = array (
|
$expected = array (
|
||||||
'C:\dev\prj2\sites\cake\libs' => array(
|
'C:\dev\prj2\sites\cake\libs' => array(
|
||||||
0 => 'C:\dev\prj2\sites\cake\libs', 1 => 'C:\dev\prj2\sites\cake\libs\view',
|
0 => 'C:\dev\prj2\sites\cake\libs', 1 => 'C:\dev\prj2\sites\cake\libs\view',
|
||||||
2 => 'C:\dev\prj2\sites\cake\libs\view\scaffolds', 3 => 'C:\dev\prj2\sites\cake\libs\view\pages',
|
2 => 'C:\dev\prj2\sites\cake\libs\view\scaffolds', 3 => 'C:\dev\prj2\sites\cake\libs\view\pages',
|
||||||
4 => 'C:\dev\prj2\sites\cake\libs\view\layouts', 5 => 'C:\dev\prj2\sites\cake\libs\view\layouts\xml',
|
4 => 'C:\dev\prj2\sites\cake\libs\view\layouts', 5 => 'C:\dev\prj2\sites\cake\libs\view\layouts\xml',
|
||||||
6 => 'C:\dev\prj2\sites\cake\libs\view\layouts\rss', 7 => 'C:\dev\prj2\sites\cake\libs\view\layouts\js',
|
6 => 'C:\dev\prj2\sites\cake\libs\view\layouts\rss', 7 => 'C:\dev\prj2\sites\cake\libs\view\layouts\js',
|
||||||
8 => 'C:\dev\prj2\sites\cake\libs\view\layouts\email', 9 => 'C:\dev\prj2\sites\cake\libs\view\layouts\email\text',
|
8 => 'C:\dev\prj2\sites\cake\libs\view\layouts\email', 9 => 'C:\dev\prj2\sites\cake\libs\view\layouts\email\text',
|
||||||
10 => 'C:\dev\prj2\sites\cake\libs\view\layouts\email\html', 11 => 'C:\dev\prj2\sites\cake\libs\view\helpers',
|
10 => 'C:\dev\prj2\sites\cake\libs\view\layouts\email\html', 11 => 'C:\dev\prj2\sites\cake\libs\view\helpers',
|
||||||
12 => 'C:\dev\prj2\sites\cake\libs\view\errors', 13 => 'C:\dev\prj2\sites\cake\libs\view\elements',
|
12 => 'C:\dev\prj2\sites\cake\libs\view\errors', 13 => 'C:\dev\prj2\sites\cake\libs\view\elements',
|
||||||
14 => 'C:\dev\prj2\sites\cake\libs\view\elements\email', 15 => 'C:\dev\prj2\sites\cake\libs\view\elements\email\text',
|
14 => 'C:\dev\prj2\sites\cake\libs\view\elements\email', 15 => 'C:\dev\prj2\sites\cake\libs\view\elements\email\text',
|
||||||
16 => 'C:\dev\prj2\sites\cake\libs\view\elements\email\html', 17 => 'C:\dev\prj2\sites\cake\libs\model',
|
16 => 'C:\dev\prj2\sites\cake\libs\view\elements\email\html', 17 => 'C:\dev\prj2\sites\cake\libs\model',
|
||||||
18 => 'C:\dev\prj2\sites\cake\libs\model\datasources', 19 => 'C:\dev\prj2\sites\cake\libs\model\datasources\dbo',
|
18 => 'C:\dev\prj2\sites\cake\libs\model\datasources', 19 => 'C:\dev\prj2\sites\cake\libs\model\datasources\dbo',
|
||||||
20 => 'C:\dev\prj2\sites\cake\libs\model\behaviors', 21 => 'C:\dev\prj2\sites\cake\libs\controller',
|
20 => 'C:\dev\prj2\sites\cake\libs\model\behaviors', 21 => 'C:\dev\prj2\sites\cake\libs\controller',
|
||||||
22 => 'C:\dev\prj2\sites\cake\libs\controller\components', 23 => 'C:\dev\prj2\sites\cake\libs\cache'),
|
22 => 'C:\dev\prj2\sites\cake\libs\controller\components', 23 => 'C:\dev\prj2\sites\cake\libs\cache'),
|
||||||
'C:\dev\prj2\sites\main_site\vendors' => array(
|
'C:\dev\prj2\sites\main_site\vendors' => array(
|
||||||
0 => 'C:\dev\prj2\sites\main_site\vendors', 1 => 'C:\dev\prj2\sites\main_site\vendors\shells',
|
0 => 'C:\dev\prj2\sites\main_site\vendors', 1 => 'C:\dev\prj2\sites\main_site\vendors\shells',
|
||||||
2 => 'C:\dev\prj2\sites\main_site\vendors\shells\templates', 3 => 'C:\dev\prj2\sites\main_site\vendors\shells\templates\cdc_project',
|
2 => 'C:\dev\prj2\sites\main_site\vendors\shells\templates', 3 => 'C:\dev\prj2\sites\main_site\vendors\shells\templates\cdc_project',
|
||||||
4 => 'C:\dev\prj2\sites\main_site\vendors\shells\tasks', 5 => 'C:\dev\prj2\sites\main_site\vendors\js',
|
4 => 'C:\dev\prj2\sites\main_site\vendors\shells\tasks', 5 => 'C:\dev\prj2\sites\main_site\vendors\js',
|
||||||
6 => 'C:\dev\prj2\sites\main_site\vendors\css'),
|
6 => 'C:\dev\prj2\sites\main_site\vendors\css'),
|
||||||
'C:\dev\prj2\sites\vendors' => array(
|
'C:\dev\prj2\sites\vendors' => array(
|
||||||
0 => 'C:\dev\prj2\sites\vendors', 1 => 'C:\dev\prj2\sites\vendors\simpletest',
|
0 => 'C:\dev\prj2\sites\vendors', 1 => 'C:\dev\prj2\sites\vendors\simpletest',
|
||||||
2 => 'C:\dev\prj2\sites\vendors\simpletest\test', 3 => 'C:\dev\prj2\sites\vendors\simpletest\test\support',
|
2 => 'C:\dev\prj2\sites\vendors\simpletest\test', 3 => 'C:\dev\prj2\sites\vendors\simpletest\test\support',
|
||||||
4 => 'C:\dev\prj2\sites\vendors\simpletest\test\support\collector', 5 => 'C:\dev\prj2\sites\vendors\simpletest\extensions',
|
4 => 'C:\dev\prj2\sites\vendors\simpletest\test\support\collector', 5 => 'C:\dev\prj2\sites\vendors\simpletest\extensions',
|
||||||
6 => 'C:\dev\prj2\sites\vendors\simpletest\extensions\testdox', 7 => 'C:\dev\prj2\sites\vendors\simpletest\docs',
|
6 => 'C:\dev\prj2\sites\vendors\simpletest\extensions\testdox', 7 => 'C:\dev\prj2\sites\vendors\simpletest\docs',
|
||||||
8 => 'C:\dev\prj2\sites\vendors\simpletest\docs\fr', 9 => 'C:\dev\prj2\sites\vendors\simpletest\docs\en'),
|
8 => 'C:\dev\prj2\sites\vendors\simpletest\docs\fr', 9 => 'C:\dev\prj2\sites\vendors\simpletest\docs\en'),
|
||||||
'C:\dev\prj2\sites\main_site\views\helpers' => array(
|
'C:\dev\prj2\sites\main_site\views\helpers' => array(
|
||||||
0 => 'C:\dev\prj2\sites\main_site\views\helpers'));
|
0 => 'C:\dev\prj2\sites\main_site\views\helpers')
|
||||||
|
);
|
||||||
|
|
||||||
$data = Cache::write('test_dir_map', $expected);
|
Cache::write('test_dir_map', $expected, 'windows_test');
|
||||||
$data = Cache::read('test_dir_map');
|
$data = Cache::read('test_dir_map', 'windows_test');
|
||||||
Cache::delete('test_dir_map');
|
Cache::delete('test_dir_map', 'windows_test');
|
||||||
$this->assertEqual($expected, $data);
|
$this->assertEqual($expected, $data);
|
||||||
|
|
||||||
|
Cache::drop('windows_test');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -349,13 +344,13 @@ class FileEngineTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testWriteQuotedString() {
|
function testWriteQuotedString() {
|
||||||
Cache::engine('File', array('path' => TMP . 'tests'));
|
Cache::config('default', array('engine' => 'File', 'path' => TMP . 'tests'));
|
||||||
Cache::write('App.doubleQuoteTest', '"this is a quoted string"');
|
Cache::write('App.doubleQuoteTest', '"this is a quoted string"');
|
||||||
$this->assertIdentical(Cache::read('App.doubleQuoteTest'), '"this is a quoted string"');
|
$this->assertIdentical(Cache::read('App.doubleQuoteTest'), '"this is a quoted string"');
|
||||||
Cache::write('App.singleQuoteTest', "'this is a quoted string'");
|
Cache::write('App.singleQuoteTest', "'this is a quoted string'");
|
||||||
$this->assertIdentical(Cache::read('App.singleQuoteTest'), "'this is a quoted string'");
|
$this->assertIdentical(Cache::read('App.singleQuoteTest'), "'this is a quoted string'");
|
||||||
|
|
||||||
Cache::engine('File', array('isWindows' => true, 'path' => TMP . 'tests'));
|
Cache::config('default', array('isWindows' => true, 'path' => TMP . 'tests'));
|
||||||
$this->assertIdentical(Cache::read('App.doubleQuoteTest'), '"this is a quoted string"');
|
$this->assertIdentical(Cache::read('App.doubleQuoteTest'), '"this is a quoted string"');
|
||||||
Cache::write('App.singleQuoteTest', "'this is a quoted string'");
|
Cache::write('App.singleQuoteTest', "'this is a quoted string'");
|
||||||
$this->assertIdentical(Cache::read('App.singleQuoteTest'), "'this is a quoted string'");
|
$this->assertIdentical(Cache::read('App.singleQuoteTest'), "'this is a quoted string'");
|
||||||
|
|
43
cake/tests/cases/libs/cache/memcache.test.php
vendored
43
cake/tests/cases/libs/cache/memcache.test.php
vendored
|
@ -2,8 +2,6 @@
|
||||||
/**
|
/**
|
||||||
* MemcacheEngineTest file
|
* MemcacheEngineTest file
|
||||||
*
|
*
|
||||||
* Long description for file
|
|
||||||
*
|
|
||||||
* PHP versions 4 and 5
|
* PHP versions 4 and 5
|
||||||
*
|
*
|
||||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||||
|
@ -23,13 +21,6 @@ if (!class_exists('Cache')) {
|
||||||
require LIBS . 'cache.php';
|
require LIBS . 'cache.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* MemcacheEngineTest class
|
|
||||||
*
|
|
||||||
* @package cake
|
|
||||||
* @subpackage cake.tests.cases.libs.cache
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MemcacheEngineTest class
|
* MemcacheEngineTest class
|
||||||
*
|
*
|
||||||
|
@ -46,10 +37,10 @@ class MemcacheEngineTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function skip() {
|
function skip() {
|
||||||
$skip = true;
|
$skip = true;
|
||||||
if (Cache::engine('Memcache')) {
|
if (class_exists('Memcache')) {
|
||||||
$skip = false;
|
$skip = false;
|
||||||
}
|
}
|
||||||
$this->skipIf($skip, '%s Memcache is not installed or configured properly');
|
$this->skipIf($skip, '%s Memcache is not installed or configured properly.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,6 +63,7 @@ class MemcacheEngineTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
Configure::write('Cache.disable', $this->_cacheDisable);
|
Configure::write('Cache.disable', $this->_cacheDisable);
|
||||||
|
Cache::drop('memcache');
|
||||||
Cache::config('default');
|
Cache::config('default');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,14 +95,12 @@ class MemcacheEngineTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function testMultipleServers() {
|
function testMultipleServers() {
|
||||||
$servers = array('127.0.0.1:11211', '127.0.0.1:11222');
|
$servers = array('127.0.0.1:11211', '127.0.0.1:11222');
|
||||||
|
|
||||||
$Cache =& Cache::getInstance();
|
|
||||||
$MemCache =& $Cache->_Engine['Memcache'];
|
|
||||||
|
|
||||||
$available = true;
|
$available = true;
|
||||||
|
$Memcache =& new Memcache();
|
||||||
|
|
||||||
foreach($servers as $server) {
|
foreach($servers as $server) {
|
||||||
list($host, $port) = explode(':', $server);
|
list($host, $port) = explode(':', $server);
|
||||||
if (!@$MemCache->__Memcache->connect($host, $port)) {
|
if (!$Memcache->addServer($host, $port)) {
|
||||||
$available = false;
|
$available = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,13 +108,13 @@ class MemcacheEngineTest extends CakeTestCase {
|
||||||
if ($this->skipIf(!$available, '%s Need memcache servers at ' . implode(', ', $servers) . ' to run this test')) {
|
if ($this->skipIf(!$available, '%s Need memcache servers at ' . implode(', ', $servers) . ' to run this test')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$Memcache =& new MemcacheEngine();
|
||||||
|
$Memcache->init(array('engine' => 'Memcache', 'servers' => $servers));
|
||||||
|
|
||||||
unset($MemCache->__Memcache);
|
$servers = array_keys($Memcache->__Memcache->getExtendedStats());
|
||||||
$MemCache->init(array('engine' => 'Memcache', 'servers' => $servers));
|
$settings = $Memcache->settings();
|
||||||
|
|
||||||
$servers = array_keys($MemCache->__Memcache->getExtendedStats());
|
|
||||||
$settings = Cache::settings();
|
|
||||||
$this->assertEqual($servers, $settings['servers']);
|
$this->assertEqual($servers, $settings['servers']);
|
||||||
|
Cache::drop('dual_server');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,8 +124,9 @@ class MemcacheEngineTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testConnect() {
|
function testConnect() {
|
||||||
$Cache =& Cache::getInstance();
|
$Memcache =& new MemcacheEngine();
|
||||||
$result = $Cache->_Engine['Memcache']->connect('127.0.0.1');
|
$Memcache->init(Cache::settings('memcache'));
|
||||||
|
$result = $Memcache->connect('127.0.0.1');
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,13 +184,13 @@ class MemcacheEngineTest extends CakeTestCase {
|
||||||
$result = Cache::read('other_test');
|
$result = Cache::read('other_test');
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
|
|
||||||
Cache::engine('Memcache', array('duration' => '+1 second'));
|
Cache::config('memcache', array('duration' => '+1 second'));
|
||||||
sleep(2);
|
sleep(2);
|
||||||
|
|
||||||
$result = Cache::read('other_test');
|
$result = Cache::read('other_test');
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
|
|
||||||
Cache::engine('Memcache', array('duration' => '+31 day'));
|
Cache::config('memcache', array('duration' => '+31 day'));
|
||||||
$data = 'this is a test of the emergency broadcasting system';
|
$data = 'this is a test of the emergency broadcasting system';
|
||||||
$result = Cache::write('long_expiry_test', $data);
|
$result = Cache::write('long_expiry_test', $data);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
|
@ -212,7 +203,7 @@ class MemcacheEngineTest extends CakeTestCase {
|
||||||
$result = Cache::read('long_expiry_test');
|
$result = Cache::read('long_expiry_test');
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
|
|
||||||
Cache::engine('Memcache', array('duration' => 3600));
|
Cache::config('memcache', array('duration' => 3600));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
2
cake/tests/cases/libs/cache/xcache.test.php
vendored
2
cake/tests/cases/libs/cache/xcache.test.php
vendored
|
@ -39,7 +39,7 @@ class XcacheEngineTest extends UnitTestCase {
|
||||||
*/
|
*/
|
||||||
function skip() {
|
function skip() {
|
||||||
$skip = true;
|
$skip = true;
|
||||||
if ($result = Cache::engine('Xcache')) {
|
if (function_exists('xcache_set')) {
|
||||||
$skip = false;
|
$skip = false;
|
||||||
}
|
}
|
||||||
$this->skipIf($skip, '%s Xcache is not installed or configured properly');
|
$this->skipIf($skip, '%s Xcache is not installed or configured properly');
|
||||||
|
|
|
@ -289,6 +289,20 @@ class SessionTest extends CakeTestCase {
|
||||||
$this->assertTrue($this->Session->check('Session Test.Test Case'));
|
$this->assertTrue($this->Session->check('Session Test.Test Case'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test key exploitation
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testKeyExploit() {
|
||||||
|
$key = "a'] = 1; phpinfo(); \$_SESSION['a";
|
||||||
|
$result = $this->Session->write($key, 'haxored');
|
||||||
|
$this->assertTrue($result);
|
||||||
|
|
||||||
|
$result = $this->Session->read($key);
|
||||||
|
$this->assertEqual($result, 'haxored');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testReadingSavedEmpty method
|
* testReadingSavedEmpty method
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue