mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
More optimization refactoring.
Fix cache but causing object_map to be created and deleted on each request. Replacing function and method calls with better performing code. git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7596 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
c9c18741fb
commit
cb487bd6e6
37 changed files with 183 additions and 182 deletions
|
@ -40,7 +40,7 @@
|
|||
* Patch for PHP < 5.0
|
||||
*/
|
||||
if (!function_exists('clone')) {
|
||||
if (version_compare(phpversion(), '5.0') < 0) {
|
||||
if (version_compare(PHP_VERSION, '5.0') < 0) {
|
||||
eval ('
|
||||
function clone($object)
|
||||
{
|
||||
|
@ -399,7 +399,7 @@ if (!function_exists('clone')) {
|
|||
return r(env('DOCUMENT_ROOT'), '', env('SCRIPT_FILENAME'));
|
||||
break;
|
||||
case 'CGI_MODE':
|
||||
return (substr(php_sapi_name(), 0, 3) == 'cgi');
|
||||
return (PHP_SAPI == 'cgi');
|
||||
break;
|
||||
case 'HTTP_BASE':
|
||||
return preg_replace ('/^([^.])*/i', null, env('HTTP_HOST'));
|
||||
|
@ -517,7 +517,7 @@ if (!function_exists('clone')) {
|
|||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
} else {
|
||||
$cache = array(
|
||||
CACHE . $type . DS . '*' . $params . $ext,
|
||||
CACHE . $type . DS . '*' . $params . '_*' . $ext
|
||||
|
@ -550,17 +550,18 @@ if (!function_exists('clone')) {
|
|||
/**
|
||||
* Recursively strips slashes from all values in an array
|
||||
*
|
||||
* @param array $value Array of values to strip slashes
|
||||
* @param array $values Array of values to strip slashes
|
||||
* @return mixed What is returned from calling stripslashes
|
||||
*/
|
||||
function stripslashes_deep($value) {
|
||||
if (is_array($value)) {
|
||||
$return = array_map('stripslashes_deep', $value);
|
||||
return $return;
|
||||
function stripslashes_deep($values) {
|
||||
if (is_array($values)) {
|
||||
foreach ($values as $key => $value) {
|
||||
$values[$key] = stripslashes_deep($value);
|
||||
}
|
||||
} else {
|
||||
$return = stripslashes($value);
|
||||
return $return ;
|
||||
$values = stripslashes($values);
|
||||
}
|
||||
return $values ;
|
||||
}
|
||||
/**
|
||||
* Returns a translated string if one is found, or the submitted message if not found.
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
if (!defined('PHP5')) {
|
||||
define ('PHP5', (phpversion() >= 5));
|
||||
define ('PHP5', (PHP_VERSION >= 5));
|
||||
}
|
||||
/**
|
||||
* Configuration, directory layout and standard libraries
|
||||
|
|
|
@ -147,7 +147,7 @@ class ShellDispatcher {
|
|||
}
|
||||
|
||||
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
|
||||
define('PHP5', (phpversion() >= 5));
|
||||
define('PHP5', (PHP_VERSION >= 5));
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(__FILE__))));
|
||||
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
|
||||
|
|
|
@ -228,12 +228,21 @@ class Dispatcher extends Object {
|
|||
$controller->beforeFilter();
|
||||
$controller->Component->startup($controller);
|
||||
|
||||
$classMethods = array_diff(
|
||||
array_map('strtolower', get_class_methods($controller)),
|
||||
array_map('strtolower', get_class_methods('Controller'))
|
||||
);
|
||||
$childMethods = get_class_methods($controller);
|
||||
$parentMethods = get_class_methods('Controller');
|
||||
|
||||
if (!in_array(strtolower($params['action']), $classMethods)) {
|
||||
foreach ($childMethods as $key => $value) {
|
||||
$childMethods[$key] = strtolower($value);
|
||||
}
|
||||
|
||||
foreach ($parentMethods as $key => $value) {
|
||||
$parentMethods[$key] = strtolower($value);
|
||||
}
|
||||
|
||||
$classMethods = array_diff($childMethods, $parentMethods);
|
||||
$classMethods = array_flip($classMethods);
|
||||
|
||||
if (!isset($classMethods[strtolower($params['action'])])) {
|
||||
if ($controller->scaffold !== false) {
|
||||
App::import('Core', 'Scaffold');
|
||||
return new Scaffold($controller, $params);
|
||||
|
@ -247,7 +256,6 @@ class Dispatcher extends Object {
|
|||
'base' => $this->base)));
|
||||
|
||||
}
|
||||
|
||||
$output = $controller->dispatchMethod($params['action'], $params['pass']);
|
||||
|
||||
if ($controller->autoRender) {
|
||||
|
@ -525,7 +533,7 @@ class Dispatcher extends Object {
|
|||
$uri = preg_replace('/^(?:\/)?(?:' . preg_quote($base, '/') . ')?(?:url=)?/', '', $uri);
|
||||
}
|
||||
|
||||
if (Configure::read('App.server') == 'IIS') {
|
||||
if (PHP_SAPI == 'isapi') {
|
||||
$uri = preg_replace('/^(?:\/)?(?:\/)?(?:\?)?(?:url=)?/', '', $uri);
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ class Cache extends Object {
|
|||
*/
|
||||
function &getInstance() {
|
||||
static $instance = array();
|
||||
if (!isset($instance[0]) || !$instance[0]) {
|
||||
if (!$instance) {
|
||||
$instance[0] =& new Cache();
|
||||
}
|
||||
return $instance[0];
|
||||
|
@ -291,7 +291,6 @@ class Cache extends Object {
|
|||
if (empty($settings)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
extract($settings);
|
||||
|
||||
if (!$_this->isInitialized($engine)) {
|
||||
|
@ -300,8 +299,8 @@ class Cache extends Object {
|
|||
if (!$key = $_this->_Engine[$engine]->key($key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$success = $_this->_Engine[$engine]->read($settings['prefix'] . $key);
|
||||
|
||||
if ($config !== $_this->__name) {
|
||||
$settings = $_this->set();
|
||||
}
|
||||
|
|
4
cake/libs/cache/file.php
vendored
4
cake/libs/cache/file.php
vendored
|
@ -91,7 +91,7 @@ class FileEngine extends CacheEngine {
|
|||
$this->__File =& new File($this->settings['path'] . DS . 'cake');
|
||||
}
|
||||
|
||||
if(substr(PHP_OS, 0, 3) == "WIN") {
|
||||
if (DIRECTORY_SEPARATOR == '\\') {
|
||||
$this->settings['isWindows'] = true;
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ class FileEngine extends CacheEngine {
|
|||
* @access public
|
||||
*/
|
||||
function read($key) {
|
||||
if($this->__setKey($key) === false || !$this->__init) {
|
||||
if($this->__setKey($key) === false || !$this->__init || !$this->__File->exists()) {
|
||||
return false;
|
||||
}
|
||||
if ($this->settings['lock']) {
|
||||
|
|
|
@ -138,7 +138,8 @@ class ClassRegistry {
|
|||
} else {
|
||||
$appModel = 'AppModel';
|
||||
}
|
||||
${$class} =& new $appModel(array_merge($settings, array('name' => $class)));
|
||||
$settings['name'] = $class;
|
||||
${$class} =& new $appModel($settings);
|
||||
}
|
||||
|
||||
if (!isset(${$class})) {
|
||||
|
@ -277,7 +278,7 @@ class ClassRegistry {
|
|||
$duplicate = false;
|
||||
if ($_this->isKeySet($alias)) {
|
||||
$model =& $_this->getObject($alias);
|
||||
if (is_a($model, $class)) {
|
||||
if (is_a($model, $class) || $model->alias == $class) {
|
||||
$duplicate =& $model;
|
||||
}
|
||||
unset($model);
|
||||
|
|
|
@ -135,7 +135,6 @@ class Configure extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function listObjects($type, $path = null, $cache = true) {
|
||||
$_this =& Configure::getInstance();
|
||||
$objects = array();
|
||||
$extension = false;
|
||||
$name = $type;
|
||||
|
@ -146,13 +145,13 @@ class Configure extends Object {
|
|||
$extension = true;
|
||||
$name = $type . str_replace(DS, '', $path);
|
||||
}
|
||||
$_this =& Configure::getInstance();
|
||||
|
||||
if (empty($_this->__objects) && $cache === true) {
|
||||
$_this->__objects = Cache::read('object_map', '_cake_core_');
|
||||
}
|
||||
|
||||
if (empty($_this->__objects) || !isset($_this->__objects[$type]) || $cache !== true) {
|
||||
$Inflector =& Inflector::getInstance();
|
||||
$types = array(
|
||||
'model' => array('suffix' => '.php', 'base' => 'AppModel', 'core' => false),
|
||||
'behavior' => array('suffix' => '.php', 'base' => 'ModelBehavior'),
|
||||
|
@ -187,7 +186,9 @@ class Configure extends Object {
|
|||
}
|
||||
|
||||
if ($type !== 'file') {
|
||||
$objects = array_map(array(&$Inflector, 'camelize'), $objects);
|
||||
foreach ($objects as $key => $value) {
|
||||
$objects[$key] = Inflector::camelize($value);
|
||||
}
|
||||
}
|
||||
if ($cache === true && !empty($objects)) {
|
||||
$_this->__objects[$name] = $objects;
|
||||
|
@ -260,13 +261,13 @@ class Configure extends Object {
|
|||
case 2:
|
||||
$_this->{$name[0]}[$name[1]] = $value;
|
||||
break;
|
||||
default:
|
||||
case 1:
|
||||
$_this->{$name[0]} = $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists('debug', $config)) {
|
||||
if (isset($config['debug'])) {
|
||||
if ($_this->debug) {
|
||||
error_reporting(E_ALL);
|
||||
|
||||
|
@ -365,7 +366,6 @@ class Configure extends Object {
|
|||
*/
|
||||
function load($fileName) {
|
||||
$found = false;
|
||||
$_this =& Configure::getInstance();
|
||||
|
||||
if (file_exists(CONFIGS . $fileName . '.php')) {
|
||||
include(CONFIGS . $fileName . '.php');
|
||||
|
@ -374,7 +374,7 @@ class Configure extends Object {
|
|||
include(CACHE . 'persistent' . DS . $fileName . '.php');
|
||||
$found = true;
|
||||
} else {
|
||||
foreach ($_this->corePaths('cake') as $key => $path) {
|
||||
foreach (Configure::corePaths('cake') as $key => $path) {
|
||||
if (file_exists($path . DS . 'config' . DS . $fileName . '.php')) {
|
||||
include($path . DS . 'config' . DS . $fileName . '.php');
|
||||
$found = true;
|
||||
|
@ -391,7 +391,7 @@ class Configure extends Object {
|
|||
trigger_error(sprintf(__("Configure::load() - no variable \$config found in %s.php", true), $fileName), E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
return $_this->write($config);
|
||||
return Configure::write($config);
|
||||
}
|
||||
/**
|
||||
* Used to determine the current version of CakePHP
|
||||
|
@ -421,7 +421,6 @@ class Configure extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function store($type, $name, $data = array()) {
|
||||
$_this =& Configure::getInstance();
|
||||
$write = true;
|
||||
$content = '';
|
||||
|
||||
|
@ -444,7 +443,7 @@ class Configure extends Object {
|
|||
if (is_null($type)) {
|
||||
$write = false;
|
||||
}
|
||||
$_this->__writeConfig($content, $name, $write);
|
||||
Configure::__writeConfig($content, $name, $write);
|
||||
}
|
||||
/**
|
||||
* Returns key => value list of all paths where core libs are found
|
||||
|
@ -601,22 +600,10 @@ class Configure extends Object {
|
|||
* @access private
|
||||
*/
|
||||
function __loadBootstrap($boot) {
|
||||
$_this =& Configure::getInstance(false);
|
||||
$modelPaths = null;
|
||||
$behaviorPaths = null;
|
||||
$controllerPaths = null;
|
||||
$componentPaths = null;
|
||||
$viewPaths = null;
|
||||
$helperPaths = null;
|
||||
$pluginPaths = null;
|
||||
$vendorPaths = null;
|
||||
$modelPaths = $behaviorPaths = $controllerPaths = $componentPaths = $viewPaths = $helperPaths = $pluginPaths = $vendorPaths = null;
|
||||
|
||||
if ($boot) {
|
||||
$_this->write('App', array('base' => false, 'baseUrl' => false, 'dir' => APP_DIR, 'webroot' => WEBROOT_DIR));
|
||||
|
||||
if (php_sapi_name() == 'isapi') {
|
||||
$_this->write('App.server', 'IIS');
|
||||
}
|
||||
Configure::write('App', array('base' => false, 'baseUrl' => false, 'dir' => APP_DIR, 'webroot' => WEBROOT_DIR));
|
||||
|
||||
if (!include(CONFIGS . 'core.php')) {
|
||||
trigger_error(sprintf(__("Can't find application core file. Please create %score.php, and make sure it is readable by PHP.", true), CONFIGS), E_USER_ERROR);
|
||||
|
@ -626,15 +613,14 @@ class Configure extends Object {
|
|||
trigger_error(sprintf(__("Can't find application bootstrap file. Please create %sbootstrap.php, and make sure it is readable by PHP.", true), CONFIGS), E_USER_ERROR);
|
||||
}
|
||||
|
||||
if ($_this->read('Cache.disable') !== true) {
|
||||
if (Configure::read('Cache.disable') !== true) {
|
||||
$cache = Cache::config('default');
|
||||
|
||||
if (empty($cache['settings'])) {
|
||||
trigger_error('Cache not configured properly. Please check Cache::config(); in APP/config/core.php', E_USER_WARNING);
|
||||
$cache = Cache::config('default', array('engine' => 'File'));
|
||||
}
|
||||
$path = null;
|
||||
$prefix = null;
|
||||
$path = $prefix = null;
|
||||
|
||||
if (!empty($cache['settings']['path'])) {
|
||||
$path = realpath($cache['settings']['path']);
|
||||
|
@ -664,7 +650,7 @@ class Configure extends Object {
|
|||
}
|
||||
Cache::config('default');
|
||||
}
|
||||
$_this->buildPaths(compact('modelPaths', 'viewPaths', 'controllerPaths', 'helperPaths', 'componentPaths', 'behaviorPaths', 'pluginPaths', 'vendorPaths'));
|
||||
Configure::buildPaths(compact('modelPaths', 'viewPaths', 'controllerPaths', 'helperPaths', 'componentPaths', 'behaviorPaths', 'pluginPaths', 'vendorPaths'));
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -744,8 +730,7 @@ class App extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function import($type = null, $name = null, $parent = true, $search = array(), $file = null, $return = false) {
|
||||
$plugin = null;
|
||||
$directory = null;
|
||||
$plugin = $directory = null;
|
||||
|
||||
if (is_array($type)) {
|
||||
extract($type, EXTR_OVERWRITE);
|
||||
|
@ -761,7 +746,6 @@ class App extends Object {
|
|||
} elseif ($name === null) {
|
||||
$type = 'File';
|
||||
}
|
||||
$_this =& App::getInstance();
|
||||
|
||||
if (is_array($name)) {
|
||||
foreach ($name as $class) {
|
||||
|
@ -785,7 +769,7 @@ class App extends Object {
|
|||
}
|
||||
}
|
||||
|
||||
if (!$_this->import($tempType, $plugin . $class)) {
|
||||
if (!App::import($tempType, $plugin . $class)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -795,6 +779,7 @@ class App extends Object {
|
|||
if ($name != null && strpos($name, '.') !== false) {
|
||||
list($plugin, $name) = explode('.', $name);
|
||||
}
|
||||
$_this =& App::getInstance();
|
||||
$_this->return = $return;
|
||||
|
||||
if (isset($ext)) {
|
||||
|
@ -981,20 +966,16 @@ class App extends Object {
|
|||
if ($plugin) {
|
||||
$plugin = Inflector::camelize($plugin);
|
||||
|
||||
if (isset($_this->__map['Plugin'][$plugin][$type])) {
|
||||
if (array_key_exists($name, $_this->__map['Plugin'][$plugin][$type])) {
|
||||
return $_this->__map['Plugin'][$plugin][$type][$name];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_this->__map[$type])) {
|
||||
if (array_key_exists($name, $_this->__map[$type])) {
|
||||
return $_this->__map[$type][$name];
|
||||
if (isset($_this->__map['Plugin'][$plugin][$type]) && isset($_this->__map['Plugin'][$plugin][$type][$name])) {
|
||||
return $_this->__map['Plugin'][$plugin][$type][$name];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($_this->__map[$type]) && isset($_this->__map[$type][$name])) {
|
||||
return $_this->__map[$type][$name];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Used to overload Objects as needed
|
||||
|
@ -1029,31 +1010,30 @@ class App extends Object {
|
|||
}
|
||||
$path = null;
|
||||
$load = strtolower($type);
|
||||
$_this = & App::getInstance();
|
||||
|
||||
switch ($load) {
|
||||
case 'model':
|
||||
if (!class_exists('Model')) {
|
||||
$_this->import('Core', 'Model', false, Configure::corePaths('model'));
|
||||
App::import('Core', 'Model', false, Configure::corePaths('model'));
|
||||
}
|
||||
$_this->import($type, 'AppModel', false, Configure::read('modelPaths'));
|
||||
App::import($type, 'AppModel', false, Configure::read('modelPaths'));
|
||||
if ($plugin) {
|
||||
$_this->import($type, $plugin . '.' . $name . 'AppModel', false, array(), $plugin . DS . $plugin . '_app_model.php');
|
||||
App::import($type, $plugin . '.' . $name . 'AppModel', false, array(), $plugin . DS . $plugin . '_app_model.php');
|
||||
$path = $plugin . DS . 'models' . DS;
|
||||
}
|
||||
return array('class' => null, 'suffix' => null, 'path' => $path);
|
||||
break;
|
||||
case 'behavior':
|
||||
$_this->import('Core', 'Behavior', false);
|
||||
App::import('Core', 'Behavior', false);
|
||||
if ($plugin) {
|
||||
$path = $plugin . DS . 'models' . DS . 'behaviors' . DS;
|
||||
}
|
||||
return array('class' => $type, 'suffix' => null, 'path' => $path);
|
||||
break;
|
||||
case 'controller':
|
||||
$_this->import($type, 'AppController', false);
|
||||
App::import($type, 'AppController', false);
|
||||
if ($plugin) {
|
||||
$_this->import($type, $plugin . '.' . $name . 'AppController', false, array(), $plugin . DS . $plugin . '_app_controller.php');
|
||||
App::import($type, $plugin . '.' . $name . 'AppController', false, array(), $plugin . DS . $plugin . '_app_controller.php');
|
||||
$path = $plugin . DS . 'controllers' . DS;
|
||||
}
|
||||
return array('class' => $type, 'suffix' => $type, 'path' => $path);
|
||||
|
@ -1071,7 +1051,7 @@ class App extends Object {
|
|||
return array('class' => $type, 'suffix' => null, 'path' => $path);
|
||||
break;
|
||||
case 'helper':
|
||||
$_this->import($type, 'AppHelper', false);
|
||||
App::import($type, 'AppHelper', false);
|
||||
if ($plugin) {
|
||||
$path = $plugin . DS . 'views' . DS . 'helpers' . DS;
|
||||
}
|
||||
|
|
|
@ -640,8 +640,8 @@ class EmailComponent extends Object{
|
|||
*/
|
||||
function __strip($value, $message = false) {
|
||||
$search = array(
|
||||
'/%0a/i', '/%0d/i', '/Content-Type\:/i', '/charset\=/i', '/mime-version\:/i',
|
||||
'/multipart\/mixed/i', '/bcc\:.*/i','/to\:.*/i','/cc\:.*/i', '/Content-Transfer-Encoding\:/i',
|
||||
'/(?:%0a)/i', '/(?:%0d)/i', '/(?:Content-Type\:)/i', '/(?:charset\=)/i', '/(?:mime-version\:)/i',
|
||||
'/(?:multipart\/mixed)/i', '/(?:bcc\:.*)/i','/(?:to\:.*)/i','/(?:cc\:.*)/i', '/(?:Content-Transfer-Encoding\:)/i',
|
||||
'/\\r/i', '/\\n/i'
|
||||
);
|
||||
|
||||
|
|
|
@ -382,7 +382,7 @@ class RequestHandlerComponent extends Object {
|
|||
if (env('HTTP_X_FORWARDED_HOST') != null) {
|
||||
$sess_host = env('HTTP_X_FORWARDED_HOST');
|
||||
}
|
||||
return trim(preg_replace('/:.*/', '', $sess_host));
|
||||
return trim(preg_replace('/(?:\:.*)/', '', $sess_host));
|
||||
}
|
||||
/**
|
||||
* Gets remote client IP
|
||||
|
@ -392,7 +392,7 @@ class RequestHandlerComponent extends Object {
|
|||
*/
|
||||
function getClientIP() {
|
||||
if (env('HTTP_X_FORWARDED_FOR') != null) {
|
||||
$ipaddr = preg_replace('/,.*/', '', env('HTTP_X_FORWARDED_FOR'));
|
||||
$ipaddr = preg_replace('/(?:,.*)/', '', env('HTTP_X_FORWARDED_FOR'));
|
||||
} else {
|
||||
if (env('HTTP_CLIENT_IP') != null) {
|
||||
$ipaddr = env('HTTP_CLIENT_IP');
|
||||
|
@ -405,7 +405,7 @@ class RequestHandlerComponent extends Object {
|
|||
$tmpipaddr = env('HTTP_CLIENTADDRESS');
|
||||
|
||||
if (!empty($tmpipaddr)) {
|
||||
$ipaddr = preg_replace('/,.*/', '', $tmpipaddr);
|
||||
$ipaddr = preg_replace('/(?:,.*)/', '', $tmpipaddr);
|
||||
}
|
||||
}
|
||||
return trim($ipaddr);
|
||||
|
@ -468,7 +468,7 @@ class RequestHandlerComponent extends Object {
|
|||
if (!$this->isPost() && !$this->isPut()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
list($contentType) = explode(';', env('CONTENT_TYPE'));
|
||||
if ($type == null) {
|
||||
return $this->mapType($contentType);
|
||||
|
@ -555,7 +555,7 @@ class RequestHandlerComponent extends Object {
|
|||
if (empty($this->__renderType)) {
|
||||
$controller->viewPath .= '/' . $type;
|
||||
} else {
|
||||
$controller->viewPath = preg_replace("/\/{$type}$/", '/' . $type, $controller->viewPath);
|
||||
$controller->viewPath = preg_replace("/(?:\/{$type})$/", '/' . $type, $controller->viewPath);
|
||||
}
|
||||
$this->__renderType = $type;
|
||||
$controller->layoutPath = $type;
|
||||
|
|
|
@ -267,7 +267,7 @@ class SecurityComponent extends Object {
|
|||
default:
|
||||
$digest = null;
|
||||
|
||||
if (version_compare(phpversion(), '5.1') != -1) {
|
||||
if (version_compare(PHP_VERSION, '5.1') != -1) {
|
||||
$digest = env('PHP_AUTH_DIGEST');
|
||||
} elseif (function_exists('apache_request_headers')) {
|
||||
$headers = apache_request_headers();
|
||||
|
@ -602,7 +602,7 @@ class SecurityComponent extends Object {
|
|||
$values = array_values($value);
|
||||
$k = array_keys($value);
|
||||
$count = count($k);
|
||||
|
||||
|
||||
if ($count > 0 && is_numeric($k[0])) {
|
||||
for ($i = 0; $count > $i; $i++) {
|
||||
foreach ($values[$i] as $key2 => $value1) {
|
||||
|
|
|
@ -137,13 +137,13 @@ class Scaffold extends Object {
|
|||
*/
|
||||
function __construct(&$controller, $params) {
|
||||
$this->controller =& $controller;
|
||||
|
||||
|
||||
$count = count($this->__passedVars);
|
||||
for ($j = 0; $j < $count; $j++) {
|
||||
$var = $this->__passedVars[$j];
|
||||
$this->{$var} = $controller->{$var};
|
||||
}
|
||||
|
||||
|
||||
$this->redirect = array('action'=> 'index');
|
||||
|
||||
if (!in_array('Form', $this->controller->helpers)) {
|
||||
|
@ -239,7 +239,7 @@ class Scaffold extends Object {
|
|||
function __scaffoldIndex($params) {
|
||||
if ($this->controller->_beforeScaffold('index')) {
|
||||
$this->ScaffoldModel->recursive = 0;
|
||||
$this->controller->set(Inflector::variable($this->controller->name), $this->controller->paginate());
|
||||
$this->controller->set(Inflector::variable($this->controller->name), $this->controller->paginate());
|
||||
$this->controller->render($this->action, $this->layout);
|
||||
$this->_output();
|
||||
} elseif ($this->controller->_scaffoldError('index') === false) {
|
||||
|
@ -321,7 +321,7 @@ class Scaffold extends Object {
|
|||
}
|
||||
|
||||
foreach ($this->ScaffoldModel->belongsTo as $assocName => $assocData) {
|
||||
$varName = Inflector::variable(Inflector::pluralize(preg_replace('/_id$/', '', $assocData['foreignKey'])));
|
||||
$varName = Inflector::variable(Inflector::pluralize(preg_replace('/(?:_id)$/', '', $assocData['foreignKey'])));
|
||||
$this->controller->set($varName, $this->ScaffoldModel->{$assocName}->find('list'));
|
||||
}
|
||||
foreach ($this->ScaffoldModel->hasAndBelongsToMany as $assocName => $assocData) {
|
||||
|
@ -503,7 +503,7 @@ class ScaffoldView extends ThemeView {
|
|||
|
||||
$names[] = $this->viewPath . DS . $subDir . $scaffoldAction;
|
||||
$names[] = 'scaffolds' . DS . $subDir . $name;
|
||||
|
||||
|
||||
$admin = Configure::read('Routing.admin');
|
||||
if (!empty($admin) && strpos($name, $admin.'_') !== false) {
|
||||
$names[] = 'scaffolds' . DS . $subDir . substr($name, strlen($admin) +1);
|
||||
|
|
|
@ -96,7 +96,7 @@ class Debugger extends Object {
|
|||
function &getInstance() {
|
||||
static $instance = array();
|
||||
|
||||
if (!isset($instance[0]) || !$instance[0]) {
|
||||
if (!$instance) {
|
||||
$instance[0] =& new Debugger();
|
||||
if (Configure::read() > 0) {
|
||||
Configure::version(); // Make sure the core config is loaded
|
||||
|
|
|
@ -211,7 +211,7 @@ class File extends Object {
|
|||
*/
|
||||
function prepare($data, $forceWindows = false) {
|
||||
$lineBreak = "\n";
|
||||
if (substr(PHP_OS,0,3) == "WIN" || $forceWindows === true) {
|
||||
if (DIRECTORY_SEPARATOR == '\\' || $forceWindows === true) {
|
||||
$lineBreak = "\r\n";
|
||||
}
|
||||
return strtr($data, array("\r\n" => $lineBreak, "\n" => $lineBreak, "\r" => $lineBreak));
|
||||
|
@ -341,7 +341,7 @@ class File extends Object {
|
|||
if (!$ext) {
|
||||
$ext = $this->ext();
|
||||
}
|
||||
return preg_replace( "/[^\w\.-]+/", "_", basename($name, $ext));
|
||||
return preg_replace( "/(?:[^\w\.-]+)/", "_", basename($name, $ext));
|
||||
}
|
||||
/**
|
||||
* Get md5 Checksum of file with previous check of Filesize
|
||||
|
|
|
@ -143,7 +143,7 @@ class Folder extends Object {
|
|||
* The returned array holds two arrays: one of dirs and one of files.
|
||||
*
|
||||
* @param boolean $sort
|
||||
* @param mixed $exceptions either an array or boolean true will no grab dot files
|
||||
* @param mixed $exceptions either an array or boolean true will not grab dot files
|
||||
* @param boolean $fullpath true returns the full path
|
||||
* @return mixed Contents of current directory as an array, false on failure
|
||||
* @access public
|
||||
|
@ -420,7 +420,7 @@ class Folder extends Object {
|
|||
while (count($this->__directories)) {
|
||||
$dir = array_pop($this->__directories);
|
||||
$this->__tree($dir, $exceptions);
|
||||
array_push($directories, $dir);
|
||||
$directories[] = $dir;
|
||||
}
|
||||
|
||||
if ($type === null) {
|
||||
|
|
|
@ -382,7 +382,7 @@ class I18n extends Object {
|
|||
}
|
||||
|
||||
if (isset($_this->__domains[$_this->category][$_this->__lang][$domain]["%po-header"]["plural-forms"])) {
|
||||
$switch = preg_replace("/[() {}\\[\\]^\\s*\\]]+/", "", $_this->__domains[$_this->category][$_this->__lang][$domain]["%po-header"]["plural-forms"]);
|
||||
$switch = preg_replace("/(?:[() {}\\[\\]^\\s*\\]]+)/", "", $_this->__domains[$_this->category][$_this->__lang][$domain]["%po-header"]["plural-forms"]);
|
||||
$_this->__domains[$_this->category][$_this->__lang][$domain]["%plural-c"] = $switch;
|
||||
unset($_this->__domains[$_this->category][$_this->__lang][$domain]["%po-header"]);
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ class Inflector extends Object {
|
|||
function &getInstance() {
|
||||
static $instance = array();
|
||||
|
||||
if (!isset($instance[0]) || !$instance[0]) {
|
||||
if (!$instance) {
|
||||
$instance[0] =& new Inflector();
|
||||
if (file_exists(CONFIGS.'inflections.php')) {
|
||||
include(CONFIGS.'inflections.php');
|
||||
|
@ -139,7 +139,6 @@ class Inflector extends Object {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
return $instance[0];
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -292,12 +292,12 @@ class BehaviorCollection extends Object {
|
|||
$this->__mappedMethods[$method] = array($alias, $name);
|
||||
}
|
||||
$methods = get_class_methods($this->{$name});
|
||||
$parentMethods = get_class_methods('ModelBehavior');
|
||||
$callbacks = array('setup', 'cleanup', 'beforeFind', 'afterFind', 'beforeSave', 'afterSave', 'beforeDelete', 'afterDelete', 'afterError');
|
||||
$parentMethods = array_flip(get_class_methods('ModelBehavior'));
|
||||
$callbacks = array('setup' => true, 'cleanup' => true, 'beforeFind' => true, 'afterFind' => true, 'beforeSave' => true, 'afterSave' => true, 'beforeDelete' => true, 'afterDelete' => true, 'afterError' => true);
|
||||
|
||||
foreach ($methods as $m) {
|
||||
if (!in_array($m, $parentMethods)) {
|
||||
if ($m[0] != '_' && !array_key_exists($m, $this->__methods) && !in_array($m, $callbacks)) {
|
||||
if (!isset($parentMethods[$m])) {
|
||||
if ($m[0] != '_' && !array_key_exists($m, $this->__methods) && !isset($callbacks[$m])) {
|
||||
$this->__methods[$m] = array($m, $name);
|
||||
}
|
||||
}
|
||||
|
@ -383,8 +383,13 @@ class BehaviorCollection extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function dispatchMethod(&$model, $method, $params = array(), $strict = false) {
|
||||
$methods = array_map('strtolower', array_keys($this->__methods));
|
||||
$found = (in_array(strtolower($method), $methods));
|
||||
$methods = array_keys($this->__methods);
|
||||
foreach ($methods as $key => $value) {
|
||||
$methods[$key] = strtolower($value);
|
||||
}
|
||||
$method = strtolower($method);
|
||||
$check = array_flip($methods);
|
||||
$found = isset($check[$method]);
|
||||
$call = null;
|
||||
|
||||
if ($strict && !$found) {
|
||||
|
@ -392,7 +397,7 @@ class BehaviorCollection extends Object {
|
|||
return null;
|
||||
} elseif ($found) {
|
||||
$methods = array_combine($methods, array_values($this->__methods));
|
||||
$call = $methods[strtolower($method)];
|
||||
$call = $methods[$method];
|
||||
} else {
|
||||
$count = count($this->__mappedMethods);
|
||||
$mapped = array_keys($this->__mappedMethods);
|
||||
|
@ -405,6 +410,7 @@ class BehaviorCollection extends Object {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($call)) {
|
||||
return $this->{$call[1]}->dispatchMethod($model, $call[0], $params);
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ class ConnectionManager extends Object {
|
|||
function &getInstance() {
|
||||
static $instance = array();
|
||||
|
||||
if (!isset($instance[0]) || !$instance[0]) {
|
||||
if (!$instance) {
|
||||
$instance[0] =& new ConnectionManager();
|
||||
}
|
||||
|
||||
|
|
|
@ -464,7 +464,7 @@ class DboSource extends DataSource {
|
|||
$text = 'query';
|
||||
}
|
||||
|
||||
if (php_sapi_name() != 'cli') {
|
||||
if (PHP_SAPI != 'cli') {
|
||||
print ("<table class=\"cake-sql-log\" id=\"cakeSqlLog_" . preg_replace('/[^A-Za-z0-9_]/', '_', uniqid(time(), true)) . "\" summary=\"Cake SQL Log\" cellspacing=\"0\" border = \"0\">\n<caption>({$this->configKeyName}) {$this->_queriesCnt} {$text} took {$this->_queriesTime} ms</caption>\n");
|
||||
print ("<thead>\n<tr><th>Nr</th><th>Query</th><th>Error</th><th>Affected</th><th>Num. rows</th><th>Took (ms)</th></tr>\n</thead>\n<tbody>\n");
|
||||
|
||||
|
|
|
@ -262,7 +262,7 @@ class Multibyte extends Object {
|
|||
function &getInstance() {
|
||||
static $instance = array();
|
||||
|
||||
if (!isset($instance[0]) || !$instance[0]) {
|
||||
if (!$instance) {
|
||||
$instance[0] =& new Multibyte();
|
||||
}
|
||||
return $instance[0];
|
||||
|
@ -372,7 +372,7 @@ class Multibyte extends Object {
|
|||
*/
|
||||
function stristr($haystack, $needle, $part = false) {
|
||||
$_this =& Multibyte::getInstance();
|
||||
$php = (phpversion() < 5.3);
|
||||
$php = (PHP_VERSION < 5.3);
|
||||
|
||||
if (($php && $part) || $_this->__checkMultibyte($haystack)) {
|
||||
$check = $_this->strtoupper($haystack);
|
||||
|
@ -706,7 +706,7 @@ class Multibyte extends Object {
|
|||
*/
|
||||
function strstr($haystack, $needle, $part = false) {
|
||||
$_this =& Multibyte::getInstance();
|
||||
$php = (phpversion() < 5.3);
|
||||
$php = (PHP_VERSION < 5.3);
|
||||
|
||||
if (($php && $part) || $_this->__checkMultibyte($haystack)) {
|
||||
$check = $_this->utf8($haystack);
|
||||
|
|
|
@ -172,7 +172,7 @@ class Router extends Object {
|
|||
function &getInstance() {
|
||||
static $instance = array();
|
||||
|
||||
if (!isset($instance[0]) || !$instance[0]) {
|
||||
if (!$instance) {
|
||||
$instance[0] =& new Router();
|
||||
$instance[0]->__admin = Configure::read('Routing.admin');
|
||||
}
|
||||
|
@ -581,8 +581,9 @@ class Router extends Object {
|
|||
}
|
||||
|
||||
if ($plugins = Configure::listObjects('plugin')) {
|
||||
$Inflector =& Inflector::getInstance();
|
||||
$plugins = array_map(array(&$Inflector, 'underscore'), $plugins);
|
||||
foreach ($plugins as $key => $value) {
|
||||
$plugins[$key] = Inflector::underscore($value);
|
||||
}
|
||||
|
||||
$match = array('plugin' => implode('|', $plugins));
|
||||
$_this->connect('/:plugin/:controller/:action/*', array(), $match);
|
||||
|
@ -886,7 +887,7 @@ class Router extends Object {
|
|||
|
||||
$output = str_replace('//', '/', $base . '/' . $output);
|
||||
} else {
|
||||
if (((strpos($url, '://')) || (strpos($url, 'javascript:') === 0) || (strpos($url, 'mailto:') === 0)) || (substr($url, 0, 1) == '#')) {
|
||||
if (((strpos($url, '://')) || (strpos($url, 'javascript:') === 0) || (strpos($url, 'mailto:') === 0)) || (!strncmp($url, '#', 1))) {
|
||||
return $url;
|
||||
}
|
||||
if (empty($url)) {
|
||||
|
@ -1184,7 +1185,7 @@ class Router extends Object {
|
|||
while (strpos($url, '//') !== false) {
|
||||
$url = str_replace('//', '/', $url);
|
||||
}
|
||||
$url = preg_replace('/(\/$)/', '', $url);
|
||||
$url = preg_replace('/(?:(\/$))/', '', $url);
|
||||
|
||||
if (empty($url)) {
|
||||
return '/';
|
||||
|
@ -1224,7 +1225,7 @@ class Router extends Object {
|
|||
*/
|
||||
function stripPlugin($base, $plugin) {
|
||||
if ($plugin != null) {
|
||||
$base = preg_replace('/' . $plugin . '/', '', $base);
|
||||
$base = preg_replace('/(?:' . $plugin . ')/', '', $base);
|
||||
$base = str_replace('//', '', $base);
|
||||
$pos1 = strrpos($base, '/');
|
||||
$char = strlen($base) - 1;
|
||||
|
@ -1251,12 +1252,12 @@ class Router extends Object {
|
|||
return $param;
|
||||
}
|
||||
|
||||
$return = preg_replace('/^[\\t ]*(?:-!)+/', '', $param);
|
||||
$return = preg_replace('/^(?:[\\t ]*(?:-!)+)/', '', $param);
|
||||
return $return;
|
||||
}
|
||||
foreach ($param as $key => $value) {
|
||||
if (is_string($value)) {
|
||||
$return[$key] = preg_replace('/^[\\t ]*(?:-!)+/', '', $value);
|
||||
$return[$key] = preg_replace('/^(?:[\\t ]*(?:-!)+)/', '', $value);
|
||||
} else {
|
||||
foreach ($value as $array => $string) {
|
||||
$return[$key][$array] = $_this->stripEscape($string);
|
||||
|
|
|
@ -814,7 +814,9 @@ class Set extends Object {
|
|||
if (is_string($list)) {
|
||||
$list = explode($sep, $list);
|
||||
if ($trim) {
|
||||
$list = array_map('trim', $list);
|
||||
foreach ($list as $key => $value) {
|
||||
$list[$key] = trim($value);
|
||||
}
|
||||
}
|
||||
if ($assoc) {
|
||||
return Set::normalize($list);
|
||||
|
|
|
@ -43,7 +43,7 @@ class String extends Object {
|
|||
function &getInstance() {
|
||||
static $instance = array();
|
||||
|
||||
if (!isset($instance[0]) || !$instance[0]) {
|
||||
if (!$instance) {
|
||||
$instance[0] =& new String();
|
||||
}
|
||||
return $instance[0];
|
||||
|
@ -156,10 +156,10 @@ class String extends Object {
|
|||
} else {
|
||||
$buffer .= $data{$tmpOffset};
|
||||
}
|
||||
if ($leftBound != $rightBound) {
|
||||
if ($leftBound != $rightBound) {
|
||||
if ($data{$tmpOffset} == $leftBound) {
|
||||
$depth++;
|
||||
}
|
||||
}
|
||||
if ($data{$tmpOffset} == $rightBound) {
|
||||
$depth--;
|
||||
}
|
||||
|
@ -240,14 +240,14 @@ class String extends Object {
|
|||
} else {
|
||||
$hashKeys = array_map('md5', array_keys($data));
|
||||
$tempData = array_combine(array_keys($data), array_values($hashKeys));
|
||||
foreach ($tempData as $key => $hashVal) {
|
||||
foreach ($tempData as $key => $hashVal) {
|
||||
$key = sprintf($format, preg_quote($key, '/'));
|
||||
$str = preg_replace($key, $hashVal, $str);
|
||||
}
|
||||
$dataReplacements = array_combine($hashKeys, array_values($data));
|
||||
foreach ($dataReplacements as $tmpHash => $data) {
|
||||
$str = str_replace($tmpHash, $data, $str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($options['format']) && isset($options['before'])) {
|
||||
|
@ -263,8 +263,8 @@ class String extends Object {
|
|||
* text but html is also available. The goal of this function is to replace all whitespace and uneeded markup around placeholders
|
||||
* that did not get replaced by Set::insert.
|
||||
*
|
||||
* @param string $str
|
||||
* @param string $options
|
||||
* @param string $str
|
||||
* @param string $options
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
|
|
|
@ -110,7 +110,7 @@ class Validation extends Object {
|
|||
function &getInstance() {
|
||||
static $instance = array();
|
||||
|
||||
if (!isset($instance[0]) || !$instance[0]) {
|
||||
if (!$instance) {
|
||||
$instance[0] =& new Validation();
|
||||
}
|
||||
return $instance[0];
|
||||
|
|
|
@ -193,7 +193,9 @@ class Helper extends Overloadable {
|
|||
if (!empty($this->themeWeb)) {
|
||||
$os = env('OS');
|
||||
if (!empty($os) && strpos($os, 'Windows') !== false) {
|
||||
$path = str_replace('/', '\\', WWW_ROOT . $this->themeWeb . $file);
|
||||
if (strpos(WWW_ROOT . $this->themeWeb . $file, '\\') !== false) {
|
||||
$path = str_replace('/', '\\', WWW_ROOT . $this->themeWeb . $file);
|
||||
}
|
||||
} else {
|
||||
$path = WWW_ROOT . $this->themeWeb . $file;
|
||||
}
|
||||
|
@ -201,7 +203,10 @@ class Helper extends Overloadable {
|
|||
$webPath = "{$this->webroot}" . $this->themeWeb . $file;
|
||||
}
|
||||
}
|
||||
return str_replace('//', '/', $webPath);
|
||||
if (strpos($webPath, '//') !== false) {
|
||||
return str_replace('//', '/', $webPath);
|
||||
}
|
||||
return $webPath;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1365,7 +1365,7 @@ class XmlManager {
|
|||
function &getInstance() {
|
||||
static $instance = array();
|
||||
|
||||
if (!isset($instance[0]) || !$instance[0]) {
|
||||
if (!$instance) {
|
||||
$instance[0] =& new XmlManager();
|
||||
}
|
||||
return $instance[0];
|
||||
|
|
|
@ -99,7 +99,7 @@ class CacheTest extends CakeTestCase {
|
|||
'duration' => 3600,
|
||||
'probability' => 100,
|
||||
'engine' => 'File',
|
||||
'isWindows' => (substr(PHP_OS, 0, 3) == "WIN")
|
||||
'isWindows' => DIRECTORY_SEPARATOR == '\\'
|
||||
);
|
||||
$this->assertEqual($expected, Cache::settings('File'));
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ class CacheTest extends CakeTestCase {
|
|||
'prefix'=> 'cake_',
|
||||
'lock' => false,
|
||||
'serialize'=> true,
|
||||
'isWindows' => (substr(PHP_OS, 0, 3) == "WIN")
|
||||
'isWindows' => DIRECTORY_SEPARATOR == '\\'
|
||||
);
|
||||
$this->assertEqual($settings, $expecting);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ class CodeCoverageManagerTest extends CakeTestCase {
|
|||
function startCase() {
|
||||
$this->_get = $_GET;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* End Case - restore GET vars.
|
||||
*
|
||||
|
@ -70,7 +70,7 @@ class CodeCoverageManagerTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testNoTestCaseSupplied() {
|
||||
if (php_sapi_name() != 'cli') {
|
||||
if (PHP_SAPI != 'cli') {
|
||||
unset($_GET['group']);
|
||||
CodeCoverageManager::start(substr(md5(microtime()), 0, 5), new CakeHtmlReporter());
|
||||
CodeCoverageManager::report(false);
|
||||
|
@ -632,7 +632,7 @@ HTML;
|
|||
}
|
||||
/**
|
||||
* testCalculateCodeCoverage method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -495,9 +495,9 @@ DIGEST;
|
|||
}
|
||||
/**
|
||||
* testValidatePostCheckbox method
|
||||
*
|
||||
*
|
||||
* First block tests un-checked checkbox
|
||||
* Second block tests checked checkbox
|
||||
* Second block tests checked checkbox
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
|
@ -528,8 +528,8 @@ DIGEST;
|
|||
unset($data['_Model']);
|
||||
$data['Model']['valid'] = '0';
|
||||
$this->assertEqual($this->Controller->data, $data);
|
||||
|
||||
|
||||
|
||||
|
||||
$this->Controller->data = array();
|
||||
$this->Controller->Security->startup($this->Controller);
|
||||
$key = $this->Controller->params['_Token']['key'];
|
||||
|
@ -721,7 +721,7 @@ DIGEST;
|
|||
|
||||
$this->assertTrue($this->Controller->data == $data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testValidateHasManyRecordsPass method
|
||||
*
|
||||
|
@ -748,7 +748,7 @@ DIGEST;
|
|||
'first_name' => 'Frodo',
|
||||
'last_name' => 'Baggins',
|
||||
'address' => '50 Bag end way',
|
||||
'city' => 'the shire',
|
||||
'city' => 'the shire',
|
||||
'phone' => 'N/A',
|
||||
'primary' => '1',
|
||||
),
|
||||
|
@ -785,7 +785,7 @@ DIGEST;
|
|||
$result = $this->Controller->Security->validatePost($this->Controller);
|
||||
$this->assertTrue($result);
|
||||
|
||||
unset($data['_Address']);
|
||||
unset($data['_Address']);
|
||||
$data['Address'][0]['id'] = '123';
|
||||
$data['Address'][1]['id'] = '124';
|
||||
|
||||
|
@ -819,7 +819,7 @@ DIGEST;
|
|||
'first_name' => 'Frodo',
|
||||
'last_name' => 'Baggins',
|
||||
'address' => '50 Bag end way',
|
||||
'city' => 'the shire',
|
||||
'city' => 'the shire',
|
||||
'phone' => 'N/A',
|
||||
'primary' => '1',
|
||||
),
|
||||
|
@ -922,7 +922,7 @@ DIGEST;
|
|||
$expected = array('username' => $user, 'password' => $pw);
|
||||
$this->assertIdentical($result, $expected);
|
||||
|
||||
if (version_compare(phpversion(), '5.1') != -1) {
|
||||
if (version_compare(PHP_VERSION, '5.1') != -1) {
|
||||
$_SERVER['PHP_AUTH_DIGEST'] = $digest = <<<DIGEST
|
||||
Digest username="Mufasa",
|
||||
realm="testrealm@host.com",
|
||||
|
|
|
@ -155,7 +155,7 @@ class TestErrorHandlerTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function skip() {
|
||||
$this->skipif ((php_sapi_name() == 'cli'), 'TestErrorHandlerTest cannot be run from console');
|
||||
$this->skipif ((PHP_SAPI == 'cli'), 'TestErrorHandlerTest cannot be run from console');
|
||||
}
|
||||
/**
|
||||
* testError method
|
||||
|
|
|
@ -37,14 +37,14 @@ App::import('Core', 'File');
|
|||
class FileTest extends CakeTestCase {
|
||||
/**
|
||||
* File property
|
||||
*
|
||||
*
|
||||
* @var mixed null
|
||||
* @access public
|
||||
*/
|
||||
var $File = null;
|
||||
/**
|
||||
* testBasic method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -102,7 +102,7 @@ class FileTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testRead method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -124,7 +124,7 @@ class FileTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testOffset method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -156,7 +156,7 @@ class FileTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testOpen method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -180,7 +180,7 @@ class FileTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testClose method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -197,7 +197,7 @@ class FileTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testCreate method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -208,7 +208,7 @@ class FileTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testOpeningNonExistantFileCreatesIt method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -221,7 +221,7 @@ class FileTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testPrepare method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -235,7 +235,7 @@ class FileTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testReadable method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -248,7 +248,7 @@ class FileTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testWritable method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -261,7 +261,7 @@ class FileTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testExecutable method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -274,7 +274,7 @@ class FileTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testLastAccess method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -288,7 +288,7 @@ class FileTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testLastChange method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -304,7 +304,7 @@ class FileTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testWrite method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -334,7 +334,7 @@ class FileTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testAppend method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -362,7 +362,7 @@ class FileTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testDelete method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -386,8 +386,8 @@ class FileTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* getTmpFile method
|
||||
*
|
||||
* @param bool $paintSkip
|
||||
*
|
||||
* @param bool $paintSkip
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -172,7 +172,7 @@ class FolderTest extends CakeTestCase {
|
|||
$filePath = $new . DS . 'test1.php';
|
||||
$File =& new File($filePath);
|
||||
$this->assertTrue($File->create());
|
||||
$copy = TMP . 'test_folder_copy';
|
||||
$copy = TMP . 'test_folder_copy';
|
||||
|
||||
$this->assertTrue($Folder->chmod($new, 0777, true));
|
||||
$this->assertEqual($File->perms(), '0777');
|
||||
|
@ -486,7 +486,7 @@ class FolderTest extends CakeTestCase {
|
|||
$folder->cd(TMP);
|
||||
$folder->delete($folder->pwd().'config_non_existant');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testDelete method
|
||||
*
|
||||
|
@ -498,22 +498,22 @@ class FolderTest extends CakeTestCase {
|
|||
$Folder =& new Folder($path, true);
|
||||
touch(TMP.'folder_delete_test' . DS . 'file1');
|
||||
touch(TMP.'folder_delete_test' . DS . 'file2');
|
||||
|
||||
|
||||
$return = $Folder->delete();
|
||||
$this->assertTrue($return);
|
||||
|
||||
|
||||
$messages = $Folder->messages();
|
||||
$errors = $Folder->errors();
|
||||
$this->assertEqual($errors, array());
|
||||
|
||||
|
||||
$expected = array(
|
||||
$path . ' created',
|
||||
$path . DS . 'file1 removed',
|
||||
$path . DS . 'file2 removed',
|
||||
$path . ' created',
|
||||
$path . DS . 'file1 removed',
|
||||
$path . DS . 'file2 removed',
|
||||
$path . ' removed'
|
||||
);
|
||||
$this->assertEqual($expected, $messages);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
|
@ -775,12 +775,12 @@ class RouterTest extends CakeTestCase {
|
|||
Router::connect('/', array('plugin' => 'pages', 'controller' => 'pages', 'action' => 'display'));
|
||||
$result = Router::parse('/');
|
||||
$expected = array('pass' => array(), 'named' => array(), 'controller' => 'pages', 'action' => 'display', 'plugin' => 'pages');
|
||||
$this->assertEqual($result, $expected);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = Router::parse('/posts/edit/0');
|
||||
$expected = array('pass' => array(0), 'named' => array(), 'controller' => 'posts', 'action' => 'edit', 'plugin' => null);
|
||||
$expected = array('pass' => array(0), 'named' => array(), 'controller' => 'posts', 'action' => 'edit', 'plugin' => null);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
|
||||
Router::reload();
|
||||
Router::connect('/posts/:id::url_title', array('controller' => 'posts', 'action' => 'view'), array('pass' => array('id', 'url_title'), 'id' => '[\d]+'));
|
||||
$result = Router::parse('/posts/5:sample-post-title');
|
||||
|
@ -1529,5 +1529,4 @@ class RouterTest extends CakeTestCase {
|
|||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -187,7 +187,7 @@ class SetTest extends CakeTestCase {
|
|||
$r = Set::merge('foo', 'bar');
|
||||
$this->assertIdentical($r, array('foo', 'bar'));
|
||||
|
||||
if (substr(phpversion(), 0, 1) >= 5) {
|
||||
if (substr(PHP_VERSION, 0, 1) >= 5) {
|
||||
$r = eval('class StaticSetCaller{static function merge($a, $b){return Set::merge($a, $b);}} return StaticSetCaller::merge("foo", "bar");');
|
||||
$this->assertIdentical($r, array('foo', 'bar'));
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
define('ST_FAILDETAIL_SEPARATOR', "->");
|
||||
}
|
||||
|
||||
if (version_compare(phpversion(), '4.4.4', '<=') ||
|
||||
php_sapi_name() == 'cgi') {
|
||||
if (version_compare(PHP_VERSION, '4.4.4', '<=') ||
|
||||
PHP_SAPI == 'cgi') {
|
||||
define('STDOUT', fopen('php://stdout', 'w'));
|
||||
define('STDERR', fopen('php://stderr', 'w'));
|
||||
register_shutdown_function(create_function('', 'fclose(STDOUT); fclose(STDERR); return true;'));
|
||||
|
|
|
@ -79,7 +79,7 @@ class CodeCoverageManager {
|
|||
*/
|
||||
function &getInstance() {
|
||||
static $instance = array();
|
||||
if (!isset($instance[0]) || !$instance[0]) {
|
||||
if (!$instance) {
|
||||
$instance[0] =& new CodeCoverageManager();
|
||||
}
|
||||
return $instance[0];
|
||||
|
|
Loading…
Reference in a new issue