Merge branch '2.4' into 2.5

Conflicts:
	lib/Cake/VERSION.txt
This commit is contained in:
mark_story 2013-08-23 12:57:08 -04:00
commit 6d45953525
77 changed files with 513 additions and 222 deletions

View file

@ -109,6 +109,9 @@ p {
padding: 6px 10px; padding: 6px 10px;
text-align: right; text-align: right;
} }
#header a, #footer a {
color: #fff;
}
/** containers **/ /** containers **/
div.form, div.form,

View file

@ -174,7 +174,7 @@ class Cache {
} }
$cacheClass = $class . 'Engine'; $cacheClass = $class . 'Engine';
if (!is_subclass_of($cacheClass, 'CacheEngine')) { if (!is_subclass_of($cacheClass, 'CacheEngine')) {
throw new CacheException(__d('cake_dev', 'Cache engines must use CacheEngine as a base class.')); throw new CacheException(__d('cake_dev', 'Cache engines must use %s as a base class.', 'CacheEngine'));
} }
self::$_engines[$name] = new $cacheClass(); self::$_engines[$name] = new $cacheClass();
if (!self::$_engines[$name]->init($config)) { if (!self::$_engines[$name]->init($config)) {

View file

@ -1,7 +1,5 @@
<?php <?php
/** /**
* Default routes that CakePHP provides as catch all routes.
*
* PHP 5 * PHP 5
* *
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
@ -26,7 +24,6 @@
* created when your application has one or more plugins. * created when your application has one or more plugins.
* *
* - `/:prefix/:plugin` a plugin shortcut route. * - `/:prefix/:plugin` a plugin shortcut route.
* - `/:prefix/:plugin/:action/*` a plugin shortcut route.
* - `/:prefix/:plugin/:controller` * - `/:prefix/:plugin/:controller`
* - `/:prefix/:plugin/:controller/:action/*` * - `/:prefix/:plugin/:controller/:action/*`
* - `/:prefix/:controller` * - `/:prefix/:controller`
@ -35,7 +32,6 @@
* If plugins are found in your application the following routes are created: * If plugins are found in your application the following routes are created:
* *
* - `/:plugin` a plugin shortcut route. * - `/:plugin` a plugin shortcut route.
* - `/:plugin/:action/*` a plugin shortcut route.
* - `/:plugin/:controller` * - `/:plugin/:controller`
* - `/:plugin/:controller/:action/*` * - `/:plugin/:controller/:action/*`
* *

View file

@ -71,7 +71,7 @@ class PhpReader implements ConfigReaderInterface {
include $file; include $file;
if (!isset($config)) { if (!isset($config)) {
throw new ConfigureException(__d('cake_dev', 'No variable $config found in %s', $file)); throw new ConfigureException(__d('cake_dev', 'No variable %s found in %s', '$config', $file));
} }
return $config; return $config;
} }

View file

@ -439,8 +439,7 @@ class ConsoleShell extends AppShell {
*/ */
protected function _routesReload() { protected function _routesReload() {
if (!$this->_loadRoutes()) { if (!$this->_loadRoutes()) {
$this->err(__d('cake_console', "There was an error loading the routes config. Please check that the file exists and is free of parse errors.")); return $this->err(__d('cake_console', "There was an error loading the routes config. Please check that the file exists and is free of parse errors."));
break;
} }
$this->out(__d('cake_console', "Routes configuration reloaded, %d routes connected", count(Router::$routes))); $this->out(__d('cake_console', "Routes configuration reloaded, %d routes connected", count(Router::$routes)));
} }

View file

@ -122,7 +122,7 @@ class ServerShell extends AppShell {
*/ */
public function main() { public function main() {
if (version_compare(PHP_VERSION, '5.4.0') < 0) { if (version_compare(PHP_VERSION, '5.4.0') < 0) {
$this->out(__d('cake_console', '<warning>This command is available on PHP5.4 or above</warning>')); $this->out(__d('cake_console', '<warning>This command is available on %s or above</warning>', 'PHP5.4'));
return; return;
} }

View file

@ -407,7 +407,7 @@ class ControllerTask extends BakeTask {
* @return array Set of controllers * @return array Set of controllers
*/ */
public function listAll($useDbConfig = null) { public function listAll($useDbConfig = null) {
if (is_null($useDbConfig)) { if ($useDbConfig === null) {
$useDbConfig = $this->connection; $useDbConfig = $this->connection;
} }
$this->__tables = $this->Model->getAllTables($useDbConfig); $this->__tables = $this->Model->getAllTables($useDbConfig);

View file

@ -243,7 +243,7 @@ class FixtureTask extends BakeTask {
} }
$tableInfo = $data['tables'][$useTable]; $tableInfo = $data['tables'][$useTable];
if (is_null($modelImport)) { if ($modelImport === null) {
$schema = $this->_generateSchema($tableInfo); $schema = $this->_generateSchema($tableInfo);
} }

View file

@ -117,8 +117,8 @@ class ProjectTask extends AppShell {
} }
$success = $this->corePath($path, $hardCode) === true; $success = $this->corePath($path, $hardCode) === true;
if ($success) { if ($success) {
$this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/index.php', CAKE_CORE_INCLUDE_PATH)); $this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in %s', CAKE_CORE_INCLUDE_PATH, 'webroot/index.php'));
$this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/test.php', CAKE_CORE_INCLUDE_PATH)); $this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in %s', CAKE_CORE_INCLUDE_PATH, 'webroot/test.php'));
} else { } else {
$this->err(__d('cake_console', 'Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s', $path . 'webroot' . DS . 'index.php')); $this->err(__d('cake_console', 'Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s', $path . 'webroot' . DS . 'index.php'));
$success = false; $success = false;

View file

@ -119,9 +119,15 @@ class ShellDispatcher {
* @return boolean Success. * @return boolean Success.
*/ */
protected function _bootstrap() { protected function _bootstrap() {
define('ROOT', $this->params['root']); if (!defined('ROOT')) {
define('APP_DIR', $this->params['app']); define('ROOT', $this->params['root']);
define('APP', $this->params['working'] . DS); }
if (!defined('APP_DIR')) {
define('APP_DIR', $this->params['app']);
}
if (!defined('APP')) {
define('APP', $this->params['working'] . DS);
}
if (!defined('WWW_ROOT')) { if (!defined('WWW_ROOT')) {
define('WWW_ROOT', APP . $this->params['webroot'] . DS); define('WWW_ROOT', APP . $this->params['webroot'] . DS);
} }

View file

@ -55,15 +55,14 @@
$this-><?php echo $currentModelName; ?>->create(); $this-><?php echo $currentModelName; ?>->create();
if ($this-><?php echo $currentModelName; ?>->save($this->request->data)) { if ($this-><?php echo $currentModelName; ?>->save($this->request->data)) {
<?php if ($wannaUseSession): ?> <?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved')); $this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'));
return $this->redirect(array('action' => 'index')); return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.'));
<?php else: ?> <?php else: ?>
return $this->flash(__('<?php echo ucfirst(strtolower($currentModelName)); ?> saved.'), array('action' => 'index')); return $this->flash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'), array('action' => 'index'));
<?php endif; ?> <?php endif; ?>
} }
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.'));
<?php endif; ?>
} }
<?php <?php
foreach (array('belongsTo', 'hasAndBelongsToMany') as $assoc): foreach (array('belongsTo', 'hasAndBelongsToMany') as $assoc):
@ -97,15 +96,14 @@
if ($this->request->is('post') || $this->request->is('put')) { if ($this->request->is('post') || $this->request->is('put')) {
if ($this-><?php echo $currentModelName; ?>->save($this->request->data)) { if ($this-><?php echo $currentModelName; ?>->save($this->request->data)) {
<?php if ($wannaUseSession): ?> <?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved')); $this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'));
return $this->redirect(array('action' => 'index')); return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.'));
<?php else: ?> <?php else: ?>
return $this->flash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'), array('action' => 'index')); return $this->flash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'), array('action' => 'index'));
<?php endif; ?> <?php endif; ?>
} }
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.'));
<?php endif; ?>
} else { } else {
$options = array('conditions' => array('<?php echo $currentModelName; ?>.' . $this-><?php echo $currentModelName; ?>->primaryKey => $id)); $options = array('conditions' => array('<?php echo $currentModelName; ?>.' . $this-><?php echo $currentModelName; ?>->primaryKey => $id));
$this->request->data = $this-><?php echo $currentModelName; ?>->find('first', $options); $this->request->data = $this-><?php echo $currentModelName; ?>->find('first', $options);
@ -142,16 +140,15 @@
$this->request->onlyAllow('post', 'delete'); $this->request->onlyAllow('post', 'delete');
if ($this-><?php echo $currentModelName; ?>->delete()) { if ($this-><?php echo $currentModelName; ?>->delete()) {
<?php if ($wannaUseSession): ?> <?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted')); $this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been deleted.'));
return $this->redirect(array('action' => 'index')); } else {
<?php else: ?> $this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be deleted. Please, try again.'));
return $this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted'), array('action' => 'index'));
<?php endif; ?>
} }
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> was not deleted'));
<?php else: ?>
return $this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> was not deleted'), array('action' => 'index'));
<?php endif; ?>
return $this->redirect(array('action' => 'index')); return $this->redirect(array('action' => 'index'));
<?php else: ?>
return $this->flash(__('The <?php echo strtolower($singularHumanName); ?> has been deleted.'), array('action' => 'index'));
} else {
return $this->flash(__('The <?php echo strtolower($singularHumanName); ?> could not be deleted. Please, try again.'), array('action' => 'index'));
}
<?php endif; ?>
} }

View file

@ -76,7 +76,7 @@ class <?php echo $controllerName; ?>Controller extends <?php echo $plugin; ?>App
echo ");\n\n"; echo ");\n\n";
endif; endif;
echo trim($actions) . "\n"; echo trim($actions);
endif; ?> endif; ?>
} }

View file

@ -179,8 +179,6 @@ if (!empty($associations['hasAndBelongsToMany'])):
$out .= "\t\t\t'limit' => '',\n"; $out .= "\t\t\t'limit' => '',\n";
$out .= "\t\t\t'offset' => '',\n"; $out .= "\t\t\t'offset' => '',\n";
$out .= "\t\t\t'finderQuery' => '',\n"; $out .= "\t\t\t'finderQuery' => '',\n";
$out .= "\t\t\t'deleteQuery' => '',\n";
$out .= "\t\t\t'insertQuery' => ''\n";
$out .= "\t\t)"; $out .= "\t\t)";
if ($i + 1 < $habtmCount) { if ($i + 1 < $habtmCount) {
$out .= ","; $out .= ",";

View file

@ -59,11 +59,11 @@ endif;
$settings = Cache::settings(); $settings = Cache::settings();
if (!empty($settings)): if (!empty($settings)):
echo '<span class="notice success">'; echo '<span class="notice success">';
echo __d('cake_dev', 'The %s is being used for core caching. To change the config edit APP/Config/core.php ', '<em>'. $settings['engine'] . 'Engine</em>'); echo __d('cake_dev', 'The %s is being used for core caching. To change the config edit %s', '<em>'. $settings['engine'] . 'Engine</em>', 'APP/Config/core.php');
echo '</span>'; echo '</span>';
else: else:
echo '<span class="notice">'; echo '<span class="notice">';
echo __d('cake_dev', 'Your cache is NOT working. Please check the settings in APP/Config/core.php'); echo __d('cake_dev', 'Your cache is NOT working. Please check the settings in %s', 'APP/Config/core.php');
echo '</span>'; echo '</span>';
endif; endif;
?> ?>
@ -80,7 +80,7 @@ endif;
echo '<span class="notice">'; echo '<span class="notice">';
echo __d('cake_dev', 'Your database configuration file is NOT present.'); echo __d('cake_dev', 'Your database configuration file is NOT present.');
echo '<br/>'; echo '<br/>';
echo __d('cake_dev', 'Rename APP/Config/database.php.default to APP/Config/database.php'); echo __d('cake_dev', 'Rename %s to %s', 'APP/Config/database.php.default', 'APP/Config/database.php');
echo '</span>'; echo '</span>';
endif; endif;
?> ?>
@ -123,7 +123,7 @@ if (isset($filePresent)):
echo '<p><span class="notice">'; echo '<p><span class="notice">';
echo __d('cake_dev', 'PCRE has not been compiled with Unicode support.'); echo __d('cake_dev', 'PCRE has not been compiled with Unicode support.');
echo '<br/>'; echo '<br/>';
echo __d('cake_dev', 'Recompile PCRE with Unicode support by adding <code>--enable-unicode-properties</code> when configuring'); echo __d('cake_dev', 'Recompile PCRE with Unicode support by adding %s when configuring', '<code>--enable-unicode-properties</code>');
echo '</span></p>'; echo '</span></p>';
} }
?> ?>
@ -147,9 +147,10 @@ if (isset($filePresent)):
<h3><?php echo __d('cake_dev', 'Editing this Page'); ?></h3> <h3><?php echo __d('cake_dev', 'Editing this Page'); ?></h3>
<p> <p>
<?php <?php
echo __d('cake_dev', 'To change the content of this page, edit: APP/View/Pages/home.ctp.<br /> echo __d('cake_dev', 'To change the content of this page, edit: %s.<br />
To change its layout, edit: APP/View/Layouts/default.ctp.<br /> To change its layout, edit: %s.<br />
You can also add some CSS styles for your pages at: APP/webroot/css.'); You can also add some CSS styles for your pages at: %s.',
'APP/View/Pages/home.ctp', 'APP/View/Layouts/default.ctp', 'APP/webroot/css');
?> ?>
</p> </p>

View file

@ -13,7 +13,6 @@
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project * @link http://cakephp.org CakePHP(tm) Project
* @package app.webroot.css * @package app.webroot.css
* @since CakePHP(tm)
* @license http://www.opensource.org/licenses/mit-license.php MIT License * @license http://www.opensource.org/licenses/mit-license.php MIT License
*/ */
@ -110,6 +109,9 @@ p {
padding: 6px 10px; padding: 6px 10px;
text-align: right; text-align: right;
} }
#header a, #footer a {
color: #fff;
}
/** containers **/ /** containers **/
div.form, div.form,

View file

@ -48,7 +48,7 @@ class ControllerAuthorize extends BaseAuthorize {
public function controller(Controller $controller = null) { public function controller(Controller $controller = null) {
if ($controller) { if ($controller) {
if (!method_exists($controller, 'isAuthorized')) { if (!method_exists($controller, 'isAuthorized')) {
throw new CakeException(__d('cake_dev', '$controller does not implement an isAuthorized() method.')); throw new CakeException(__d('cake_dev', '$controller does not implement an %s method.', 'isAuthorized()'));
} }
} }
return parent::controller($controller); return parent::controller($controller);

View file

@ -495,7 +495,7 @@ class AuthComponent extends Component {
throw new CakeException(__d('cake_dev', 'Authorization adapter "%s" was not found.', $class)); throw new CakeException(__d('cake_dev', 'Authorization adapter "%s" was not found.', $class));
} }
if (!method_exists($className, 'authorize')) { if (!method_exists($className, 'authorize')) {
throw new CakeException(__d('cake_dev', 'Authorization objects must implement an %s method.', 'authorize')); throw new CakeException(__d('cake_dev', 'Authorization objects must implement an %s method.', 'authorize()'));
} }
$settings = array_merge($global, (array)$settings); $settings = array_merge($global, (array)$settings);
$this->_authorizeObjects[] = new $className($this->_Collection, $settings); $this->_authorizeObjects[] = new $className($this->_Collection, $settings);
@ -717,7 +717,7 @@ class AuthComponent extends Component {
* @return string Redirect URL * @return string Redirect URL
*/ */
public function redirectUrl($url = null) { public function redirectUrl($url = null) {
if (!is_null($url)) { if ($url !== null) {
$redir = $url; $redir = $url;
$this->Session->write('Auth.redirect', $redir); $this->Session->write('Auth.redirect', $redir);
} elseif ($this->Session->check('Auth.redirect')) { } elseif ($this->Session->check('Auth.redirect')) {
@ -784,7 +784,7 @@ class AuthComponent extends Component {
throw new CakeException(__d('cake_dev', 'Authentication adapter "%s" was not found.', $class)); throw new CakeException(__d('cake_dev', 'Authentication adapter "%s" was not found.', $class));
} }
if (!method_exists($className, 'authenticate')) { if (!method_exists($className, 'authenticate')) {
throw new CakeException(__d('cake_dev', 'Authentication objects must implement an %s method.', 'authenticate')); throw new CakeException(__d('cake_dev', 'Authentication objects must implement an %s method.', 'authenticate()'));
} }
$settings = array_merge($global, (array)$settings); $settings = array_merge($global, (array)$settings);
$this->_authenticateObjects[] = new $className($this->_Collection, $settings); $this->_authenticateObjects[] = new $className($this->_Collection, $settings);

View file

@ -219,7 +219,7 @@ class CookieComponent extends Component {
$this->read(); $this->read();
} }
if (is_null($encrypt)) { if ($encrypt === null) {
$encrypt = true; $encrypt = true;
} }
$this->_encrypted = $encrypt; $this->_encrypted = $encrypt;
@ -262,7 +262,7 @@ class CookieComponent extends Component {
if (empty($this->_values[$this->name])) { if (empty($this->_values[$this->name])) {
$this->_values[$this->name] = array(); $this->_values[$this->name] = array();
} }
if (is_null($key)) { if ($key === null) {
return $this->_values[$this->name]; return $this->_values[$this->name];
} }
@ -387,7 +387,7 @@ class CookieComponent extends Component {
* @return integer Unix timestamp * @return integer Unix timestamp
*/ */
protected function _expire($expires = null) { protected function _expire($expires = null) {
if (is_null($expires)) { if ($expires === null) {
return $this->_expires; return $this->_expires;
} }
$this->_reset = $this->_expires; $this->_reset = $this->_expires;

View file

@ -228,7 +228,7 @@ class CakePlugin {
* @return void * @return void
*/ */
public static function unload($plugin = null) { public static function unload($plugin = null) {
if (is_null($plugin)) { if ($plugin === null) {
self::$_plugins = array(); self::$_plugins = array();
} else { } else {
unset(self::$_plugins[$plugin]); unset(self::$_plugins[$plugin]);

View file

@ -340,7 +340,7 @@ class Configure {
throw new ConfigureException(__d('cake_dev', 'There is no "%s" adapter.', $config)); throw new ConfigureException(__d('cake_dev', 'There is no "%s" adapter.', $config));
} }
if (!method_exists($reader, 'dump')) { if (!method_exists($reader, 'dump')) {
throw new ConfigureException(__d('cake_dev', 'The "%s" adapter, does not have a dump() method.', $config)); throw new ConfigureException(__d('cake_dev', 'The "%s" adapter, does not have a %s method.', $config, 'dump()'));
} }
$values = self::$_values; $values = self::$_values;
if (!empty($keys) && is_array($keys)) { if (!empty($keys) && is_array($keys)) {

View file

@ -161,7 +161,7 @@ class I18n {
$_this->_lang = $lang; $_this->_lang = $lang;
} }
if (is_null($domain)) { if ($domain === null) {
$domain = self::$defaultDomain; $domain = self::$defaultDomain;
} }
if ($domain === '') { if ($domain === '') {

View file

@ -65,7 +65,7 @@ class AclBehavior extends ModelBehavior {
$model->{$type} = ClassRegistry::init($type); $model->{$type} = ClassRegistry::init($type);
} }
if (!method_exists($model, 'parentNode')) { if (!method_exists($model, 'parentNode')) {
trigger_error(__d('cake_dev', 'Callback parentNode() not defined in %s', $model->alias), E_USER_WARNING); trigger_error(__d('cake_dev', 'Callback %s not defined in %s', 'parentNode()', $model->alias), E_USER_WARNING);
} }
} }

View file

@ -269,7 +269,7 @@ class ContainableBehavior extends ModelBehavior {
* @return array Containments * @return array Containments
*/ */
public function containments(Model $Model, $contain, $containments = array(), $throwErrors = null) { public function containments(Model $Model, $contain, $containments = array(), $throwErrors = null) {
$options = array('className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery', 'deleteQuery', 'insertQuery'); $options = array('className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery');
$keep = array(); $keep = array();
if ($throwErrors === null) { if ($throwErrors === null) {
$throwErrors = (empty($this->settings[$Model->alias]) ? true : $this->settings[$Model->alias]['notices']); $throwErrors = (empty($this->settings[$Model->alias]) ? true : $this->settings[$Model->alias]['notices']);

View file

@ -513,7 +513,7 @@ class TranslateBehavior extends ModelBehavior {
* @return mixed string or false * @return mixed string or false
*/ */
protected function _getLocale(Model $Model) { protected function _getLocale(Model $Model) {
if (!isset($Model->locale) || is_null($Model->locale)) { if (!isset($Model->locale) || $Model->locale === null) {
$I18n = I18n::getInstance(); $I18n = I18n::getInstance();
$I18n->l10n->get(Configure::read('Config.language')); $I18n->l10n->get(Configure::read('Config.language'));
$Model->locale = $I18n->l10n->locale; $Model->locale = $I18n->l10n->locale;
@ -588,7 +588,7 @@ class TranslateBehavior extends ModelBehavior {
$this->_removeField($Model, $field); $this->_removeField($Model, $field);
if (is_null($association)) { if ($association === null) {
if ($reset) { if ($reset) {
$this->runtime[$Model->alias]['fields'][] = $field; $this->runtime[$Model->alias]['fields'][] = $field;
} else { } else {
@ -677,7 +677,7 @@ class TranslateBehavior extends ModelBehavior {
$this->_removeField($Model, $field); $this->_removeField($Model, $field);
if (!is_null($association) && (isset($Model->hasMany[$association]) || isset($Model->__backAssociation['hasMany'][$association]))) { if ($association !== null && (isset($Model->hasMany[$association]) || isset($Model->__backAssociation['hasMany'][$association]))) {
$associations[] = $association; $associations[] = $association;
} }
} }

View file

@ -307,7 +307,7 @@ class TreeBehavior extends ModelBehavior {
extract($this->settings[$Model->alias]); extract($this->settings[$Model->alias]);
if (!is_null($overrideRecursive)) { if ($overrideRecursive !== null) {
$recursive = $overrideRecursive; $recursive = $overrideRecursive;
} }
if (!$order) { if (!$order) {
@ -353,7 +353,7 @@ class TreeBehavior extends ModelBehavior {
public function generateTreeList(Model $Model, $conditions = null, $keyPath = null, $valuePath = null, $spacer = '_', $recursive = null) { public function generateTreeList(Model $Model, $conditions = null, $keyPath = null, $valuePath = null, $spacer = '_', $recursive = null) {
$overrideRecursive = $recursive; $overrideRecursive = $recursive;
extract($this->settings[$Model->alias]); extract($this->settings[$Model->alias]);
if (!is_null($overrideRecursive)) { if ($overrideRecursive !== null) {
$recursive = $overrideRecursive; $recursive = $overrideRecursive;
} }
@ -415,7 +415,7 @@ class TreeBehavior extends ModelBehavior {
$id = $Model->id; $id = $Model->id;
} }
extract($this->settings[$Model->alias]); extract($this->settings[$Model->alias]);
if (!is_null($overrideRecursive)) { if ($overrideRecursive !== null) {
$recursive = $overrideRecursive; $recursive = $overrideRecursive;
} }
$parentId = $Model->find('first', array('conditions' => array($Model->primaryKey => $id), 'fields' => array($parent), 'recursive' => -1)); $parentId = $Model->find('first', array('conditions' => array($Model->primaryKey => $id), 'fields' => array($parent), 'recursive' => -1));
@ -448,7 +448,7 @@ class TreeBehavior extends ModelBehavior {
$id = $Model->id; $id = $Model->id;
} }
extract($this->settings[$Model->alias]); extract($this->settings[$Model->alias]);
if (!is_null($overrideRecursive)) { if ($overrideRecursive !== null) {
$recursive = $overrideRecursive; $recursive = $overrideRecursive;
} }
$result = $Model->find('first', array('conditions' => array($Model->escapeField() => $id), 'fields' => array($left, $right), 'recursive' => $recursive)); $result = $Model->find('first', array('conditions' => array($Model->escapeField() => $id), 'fields' => array($left, $right), 'recursive' => $recursive));
@ -876,7 +876,7 @@ class TreeBehavior extends ModelBehavior {
)))); ))));
foreach ($Model->find('all', array('conditions' => $scope, 'recursive' => 0)) as $instance) { foreach ($Model->find('all', array('conditions' => $scope, 'recursive' => 0)) as $instance) {
if (is_null($instance[$Model->alias][$left]) || is_null($instance[$Model->alias][$right])) { if ($instance[$Model->alias][$left] === null || $instance[$Model->alias][$right] === null) {
$errors[] = array('node', $instance[$Model->alias][$Model->primaryKey], $errors[] = array('node', $instance[$Model->alias][$Model->primaryKey],
'has invalid left or right values'); 'has invalid left or right values');
} elseif ($instance[$Model->alias][$left] == $instance[$Model->alias][$right]) { } elseif ($instance[$Model->alias][$left] == $instance[$Model->alias][$right]) {

View file

@ -228,7 +228,7 @@ class BehaviorCollection extends ObjectCollection implements CakeEventListener {
$method = $this->hasMethod($method, true); $method = $this->hasMethod($method, true);
if ($strict && empty($method)) { if ($strict && empty($method)) {
trigger_error(__d('cake_dev', "BehaviorCollection::dispatchMethod() - Method %s not found in any attached behavior", $method), E_USER_WARNING); trigger_error(__d('cake_dev', '%s - Method %s not found in any attached behavior', 'BehaviorCollection::dispatchMethod()', $method), E_USER_WARNING);
return null; return null;
} }
if (empty($method)) { if (empty($method)) {

View file

@ -366,7 +366,7 @@ class CakeSession {
if (!self::start()) { if (!self::start()) {
return false; return false;
} }
if (is_null($name)) { if ($name === null) {
return self::_returnSessionVars(); return self::_returnSessionVars();
} }
if (empty($name)) { if (empty($name)) {
@ -554,7 +554,6 @@ class CakeSession {
'session.serialize_handler' => 'php', 'session.serialize_handler' => 'php',
'session.use_cookies' => 1, 'session.use_cookies' => 1,
'session.cookie_path' => self::$path, 'session.cookie_path' => self::$path,
'session.auto_start' => 0,
'session.save_path' => TMP . 'sessions', 'session.save_path' => TMP . 'sessions',
'session.save_handler' => 'files' 'session.save_handler' => 'files'
) )
@ -565,7 +564,6 @@ class CakeSession {
'ini' => array( 'ini' => array(
'session.use_trans_sid' => 0, 'session.use_trans_sid' => 0,
'url_rewriter.tags' => '', 'url_rewriter.tags' => '',
'session.auto_start' => 0,
'session.use_cookies' => 1, 'session.use_cookies' => 1,
'session.cookie_path' => self::$path, 'session.cookie_path' => self::$path,
'session.save_handler' => 'user', 'session.save_handler' => 'user',
@ -581,7 +579,6 @@ class CakeSession {
'ini' => array( 'ini' => array(
'session.use_trans_sid' => 0, 'session.use_trans_sid' => 0,
'url_rewriter.tags' => '', 'url_rewriter.tags' => '',
'session.auto_start' => 0,
'session.use_cookies' => 1, 'session.use_cookies' => 1,
'session.cookie_path' => self::$path, 'session.cookie_path' => self::$path,
'session.save_handler' => 'user', 'session.save_handler' => 'user',

View file

@ -677,7 +677,7 @@ class Mysql extends DboSource {
* @return string Formatted length part of an index field * @return string Formatted length part of an index field
*/ */
protected function _buildIndexSubPart($lengths, $column) { protected function _buildIndexSubPart($lengths, $column) {
if (is_null($lengths)) { if ($lengths === null) {
return ''; return '';
} }
if (!isset($lengths[$column])) { if (!isset($lengths[$column])) {

View file

@ -753,11 +753,11 @@ class Postgres extends DboSource {
switch ($type) { switch ($type) {
case 'bool': case 'bool':
$resultRow[$table][$column] = is_null($row[$index]) ? null : $this->boolean($row[$index]); $resultRow[$table][$column] = $row[$index] === null ? null : $this->boolean($row[$index]);
break; break;
case 'binary': case 'binary':
case 'bytea': case 'bytea':
$resultRow[$table][$column] = is_null($row[$index]) ? null : stream_get_contents($row[$index]); $resultRow[$table][$column] = $row[$index] === null ? null : stream_get_contents($row[$index]);
break; break;
default: default:
$resultRow[$table][$column] = $row[$index]; $resultRow[$table][$column] = $row[$index];

View file

@ -357,7 +357,7 @@ class Sqlite extends DboSource {
foreach ($this->map as $col => $meta) { foreach ($this->map as $col => $meta) {
list($table, $column, $type) = $meta; list($table, $column, $type) = $meta;
$resultRow[$table][$column] = $row[$col]; $resultRow[$table][$column] = $row[$col];
if ($type === 'boolean' && !is_null($row[$col])) { if ($type === 'boolean' && $row[$col] !== null) {
$resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]); $resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]);
} }
} }

View file

@ -620,7 +620,7 @@ class Sqlserver extends DboSource {
continue; continue;
} }
$resultRow[$table][$column] = $row[$col]; $resultRow[$table][$column] = $row[$col];
if ($type === 'boolean' && !is_null($row[$col])) { if ($type === 'boolean' && $row[$col] !== null) {
$resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]); $resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]);
} }
} }

View file

@ -1035,7 +1035,7 @@ class DboSource extends DataSource {
$recursive = $queryData['recursive']; $recursive = $queryData['recursive'];
} }
if (!is_null($recursive)) { if ($recursive !== null) {
$_recursive = $model->recursive; $_recursive = $model->recursive;
$model->recursive = $recursive; $model->recursive = $recursive;
} }
@ -1123,7 +1123,7 @@ class DboSource extends DataSource {
} }
} }
if (!is_null($recursive)) { if ($recursive !== null) {
$model->recursive = $_recursive; $model->recursive = $_recursive;
} }
return $resultSet; return $resultSet;

View file

@ -464,8 +464,8 @@ class Model extends Object implements CakeEventListener {
* - `limit`: The maximum number of associated rows you want returned. * - `limit`: The maximum number of associated rows you want returned.
* - `offset`: The number of associated rows to skip over (given the current * - `offset`: The number of associated rows to skip over (given the current
* conditions and order) before fetching and associating. * conditions and order) before fetching and associating.
* - `finderQuery`, `deleteQuery`, `insertQuery`: A complete SQL query CakePHP * - `finderQuery`, A complete SQL query CakePHP
* can use to fetch, delete, or create new associated model records. This should * can use to fetch associated model records. This should
* be used in situations that require very custom results. * be used in situations that require very custom results.
* *
* @var array * @var array
@ -555,7 +555,7 @@ class Model extends Object implements CakeEventListener {
'belongsTo' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'counterCache'), 'belongsTo' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'counterCache'),
'hasOne' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'dependent'), 'hasOne' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'dependent'),
'hasMany' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'dependent', 'exclusive', 'finderQuery', 'counterQuery'), 'hasMany' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'dependent', 'exclusive', 'finderQuery', 'counterQuery'),
'hasAndBelongsToMany' => array('className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery', 'deleteQuery', 'insertQuery') 'hasAndBelongsToMany' => array('className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery')
); );
/** /**
@ -2715,7 +2715,7 @@ class Model extends Object implements CakeEventListener {
$this->id = $this->getID(); $this->id = $this->getID();
$query = $this->buildQuery($type, $query); $query = $this->buildQuery($type, $query);
if (is_null($query)) { if ($query === null) {
return null; return null;
} }

View file

@ -81,7 +81,7 @@ class Permission extends AppModel {
* @param string $action Action (defaults to *) * @param string $action Action (defaults to *)
* @return boolean Success (true if ARO has access to action in ACO, false otherwise) * @return boolean Success (true if ARO has access to action in ACO, false otherwise)
*/ */
public function check($aro, $aco, $action = "*") { public function check($aro, $aco, $action = '*') {
if (!$aro || !$aco) { if (!$aro || !$aco) {
return false; return false;
} }
@ -91,17 +91,29 @@ class Permission extends AppModel {
$acoPath = $this->Aco->node($aco); $acoPath = $this->Aco->node($aco);
if (!$aroPath || !$acoPath) { if (!$aroPath || !$acoPath) {
trigger_error(__d('cake_dev', "DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node references:\nAro: %s\nAco: %s", print_r($aro, true), print_r($aco, true)), E_USER_WARNING); trigger_error(__d('cake_dev',
"%s - Failed ARO/ACO node lookup in permissions check. Node references:\nAro: %s\nAco: %s",
'DbAcl::check()',
print_r($aro, true),
print_r($aco, true)),
E_USER_WARNING
);
return false; return false;
} }
if (!$acoPath) { if (!$acoPath) {
trigger_error(__d('cake_dev', "DbAcl::check() - Failed ACO node lookup in permissions check. Node references:\nAro: %s\nAco: %s", print_r($aro, true), print_r($aco, true)), E_USER_WARNING); trigger_error(__d('cake_dev',
"%s - Failed ACO node lookup in permissions check. Node references:\nAro: %s\nAco: %s",
'DbAcl::check()',
print_r($aro, true),
print_r($aco, true)),
E_USER_WARNING
);
return false; return false;
} }
if ($action !== '*' && !in_array('_' . $action, $permKeys)) { if ($action !== '*' && !in_array('_' . $action, $permKeys)) {
trigger_error(__d('cake_dev', "ACO permissions key %s does not exist in DbAcl::check()", $action), E_USER_NOTICE); trigger_error(__d('cake_dev', "ACO permissions key %s does not exist in %s", $action, 'DbAcl::check()'), E_USER_NOTICE);
return false; return false;
} }
@ -166,20 +178,20 @@ class Permission extends AppModel {
* @return boolean Success * @return boolean Success
* @throws AclException on Invalid permission key. * @throws AclException on Invalid permission key.
*/ */
public function allow($aro, $aco, $actions = "*", $value = 1) { public function allow($aro, $aco, $actions = '*', $value = 1) {
$perms = $this->getAclLink($aro, $aco); $perms = $this->getAclLink($aro, $aco);
$permKeys = $this->getAcoKeys($this->schema()); $permKeys = $this->getAcoKeys($this->schema());
$save = array(); $save = array();
if (!$perms) { if (!$perms) {
trigger_error(__d('cake_dev', 'DbAcl::allow() - Invalid node'), E_USER_WARNING); trigger_error(__d('cake_dev', '%s - Invalid node', 'DbAcl::allow()'), E_USER_WARNING);
return false; return false;
} }
if (isset($perms[0])) { if (isset($perms[0])) {
$save = $perms[0][$this->alias]; $save = $perms[0][$this->alias];
} }
if ($actions === "*") { if ($actions === '*') {
$save = array_combine($permKeys, array_pad(array(), count($permKeys), $value)); $save = array_combine($permKeys, array_pad(array(), count($permKeys), $value));
} else { } else {
if (!is_array($actions)) { if (!is_array($actions)) {

View file

@ -516,7 +516,7 @@ class CakeResponse {
*/ */
protected function _sendHeader($name, $value = null) { protected function _sendHeader($name, $value = null) {
if (!headers_sent()) { if (!headers_sent()) {
if (is_null($value)) { if ($value === null) {
header($name); header($name);
} else { } else {
header("{$name}: {$value}"); header("{$name}: {$value}");
@ -562,7 +562,7 @@ class CakeResponse {
* @return array list of headers to be sent * @return array list of headers to be sent
*/ */
public function header($header = null, $value = null) { public function header($header = null, $value = null) {
if (is_null($header)) { if ($header === null) {
return $this->_headers; return $this->_headers;
} }
$headers = is_array($header) ? $header : array($header => $value); $headers = is_array($header) ? $header : array($header => $value);
@ -602,7 +602,7 @@ class CakeResponse {
* @return string current message buffer if $content param is passed as null * @return string current message buffer if $content param is passed as null
*/ */
public function body($content = null) { public function body($content = null) {
if (is_null($content)) { if ($content === null) {
return $this->_body; return $this->_body;
} }
return $this->_body = $content; return $this->_body = $content;
@ -617,7 +617,7 @@ class CakeResponse {
* @throws CakeException When an unknown status code is reached. * @throws CakeException When an unknown status code is reached.
*/ */
public function statusCode($code = null) { public function statusCode($code = null) {
if (is_null($code)) { if ($code === null) {
return $this->_status; return $this->_status;
} }
if (!isset($this->_statusCodes[$code])) { if (!isset($this->_statusCodes[$code])) {
@ -702,7 +702,7 @@ class CakeResponse {
* @return mixed current content type or false if supplied an invalid content type * @return mixed current content type or false if supplied an invalid content type
*/ */
public function type($contentType = null) { public function type($contentType = null) {
if (is_null($contentType)) { if ($contentType === null) {
return $this->_contentType; return $this->_contentType;
} }
if (is_array($contentType)) { if (is_array($contentType)) {
@ -765,7 +765,7 @@ class CakeResponse {
* @return string current charset * @return string current charset
*/ */
public function charset($charset = null) { public function charset($charset = null) {
if (is_null($charset)) { if ($charset === null) {
return $this->_charset; return $this->_charset;
} }
return $this->_charset = $charset; return $this->_charset = $charset;
@ -1272,7 +1272,7 @@ class CakeResponse {
$extension = strtolower($file->ext()); $extension = strtolower($file->ext());
$download = $options['download']; $download = $options['download'];
if ((!$extension || $this->type($extension) === false) && is_null($download)) { if ((!$extension || $this->type($extension) === false) && $download === null) {
$download = true; $download = true;
} }
@ -1289,7 +1289,7 @@ class CakeResponse {
if (!empty($contentType)) { if (!empty($contentType)) {
$this->type($contentType); $this->type($contentType);
} }
if (is_null($options['name'])) { if ($options['name'] === null) {
$name = $file->name; $name = $file->name;
} else { } else {
$name = $options['name']; $name = $options['name'];

View file

@ -231,7 +231,7 @@ class SmtpTransport extends AbstractTransport {
* @throws SocketException * @throws SocketException
*/ */
protected function _smtpSend($data, $checkCode = '250') { protected function _smtpSend($data, $checkCode = '250') {
if (!is_null($data)) { if ($data !== null) {
$this->_socket->write($data . "\r\n"); $this->_socket->write($data . "\r\n");
} }
while ($checkCode !== false) { while ($checkCode !== false) {

View file

@ -550,7 +550,7 @@ class HttpSocket extends CakeSocket {
* @return mixed Either false on failure or a string containing the composed URL. * @return mixed Either false on failure or a string containing the composed URL.
*/ */
public function url($url = null, $uriTemplate = null) { public function url($url = null, $uriTemplate = null) {
if (is_null($url)) { if ($url === null) {
$url = '/'; $url = '/';
} }
if (is_string($url)) { if (is_string($url)) {

View file

@ -138,7 +138,7 @@ class HttpSocketResponse implements ArrayAccess {
* @return boolean * @return boolean
*/ */
public function isRedirect() { public function isRedirect() {
return in_array($this->code, array(301, 302, 303, 307)) && !is_null($this->getHeader('Location')); return in_array($this->code, array(301, 302, 303, 307)) && $this->getHeader('Location') !== null;
} }
/** /**

View file

@ -80,6 +80,13 @@ class RedirectRoute extends CakeRoute {
} }
if (isset($this->options['persist']) && is_array($redirect)) { if (isset($this->options['persist']) && is_array($redirect)) {
$redirect += array('named' => $params['named'], 'pass' => $params['pass'], 'url' => array()); $redirect += array('named' => $params['named'], 'pass' => $params['pass'], 'url' => array());
if (is_array($this->options['persist'])) {
foreach ($this->options['persist'] as $elem) {
if (isset($params[$elem])) {
$redirect[$elem] = $params[$elem];
}
}
}
$redirect = Router::reverse($redirect); $redirect = Router::reverse($redirect);
} }
$status = 301; $status = 301;

View file

@ -183,7 +183,7 @@ class Router {
* @throws RouterException * @throws RouterException
*/ */
public static function defaultRouteClass($routeClass = null) { public static function defaultRouteClass($routeClass = null) {
if (is_null($routeClass)) { if ($routeClass === null) {
return self::$_routeClass; return self::$_routeClass;
} }

View file

@ -282,29 +282,17 @@ class ControllerTaskTest extends CakeTestCase {
$components = array('Acl', 'Auth'); $components = array('Acl', 'Auth');
$this->Task->expects($this->any())->method('createFile')->will($this->returnValue(true)); $this->Task->expects($this->any())->method('createFile')->will($this->returnValue(true));
$result = $this->Task->bake('Articles', '--actions--', $helpers, $components); $result = $this->Task->bake('Articles', null, $helpers, $components);
$this->assertContains(' * @property Article $Article', $result); $expected = file_get_contents(CAKE . 'Test' . DS . 'bake_compare' . DS . 'Controller' . DS . 'NoActions.ctp');
$this->assertContains(' * @property AclComponent $Acl', $result); $this->assertTextEquals($expected, $result);
$this->assertContains(' * @property AuthComponent $Auth', $result);
$this->assertContains(' * @property PaginatorComponent $Paginator', $result); $result = $this->Task->bake('Articles', null, array(), array());
$this->assertContains('class ArticlesController extends AppController', $result); $expected = file_get_contents(CAKE . 'Test' . DS . 'bake_compare' . DS . 'Controller' . DS . 'NoHelpersOrComponents.ctp');
$this->assertContains("public \$components = array('Acl', 'Auth', 'Paginator')", $result); $this->assertTextEquals($expected, $result);
$this->assertContains("public \$helpers = array('Js', 'Time')", $result);
$this->assertContains("--actions--", $result);
$result = $this->Task->bake('Articles', 'scaffold', $helpers, $components); $result = $this->Task->bake('Articles', 'scaffold', $helpers, $components);
$this->assertContains("class ArticlesController extends AppController", $result); $expected = file_get_contents(CAKE . 'Test' . DS . 'bake_compare' . DS . 'Controller' . DS . 'Scaffold.ctp');
$this->assertContains("public \$scaffold", $result); $this->assertTextEquals($expected, $result);
$this->assertNotContains('@property', $result);
$this->assertNotContains('helpers', $result);
$this->assertNotContains('components', $result);
$result = $this->Task->bake('Articles', '--actions--', array(), array());
$this->assertContains('class ArticlesController extends AppController', $result);
$this->assertSame(substr_count($result, '@property'), 2);
$this->assertContains("public \$components = array('Paginator')", $result);
$this->assertNotContains('helpers', $result);
$this->assertContains('--actions--', $result);
} }
/** /**
@ -348,30 +336,10 @@ class ControllerTaskTest extends CakeTestCase {
*/ */
public function testBakeActionsUsingSessions() { public function testBakeActionsUsingSessions() {
$result = $this->Task->bakeActions('BakeArticles', null, true); $result = $this->Task->bakeActions('BakeArticles', null, true);
$expected = file_get_contents(CAKE . 'Test' . DS . 'bake_compare' . DS . 'Controller' . DS . 'ActionsUsingSessions.ctp');
$this->assertContains('function index() {', $result); $this->assertTextEquals($expected, $result);
$this->assertContains('$this->BakeArticle->recursive = 0;', $result);
$this->assertContains("\$this->set('bakeArticles', \$this->Paginator->paginate());", $result);
$this->assertContains('function view($id = null)', $result);
$this->assertContains("throw new NotFoundException(__('Invalid bake article'));", $result);
$this->assertContains("\$options = array('conditions' => array('BakeArticle.' . \$this->BakeArticle->primaryKey => \$id));", $result);
$this->assertContains("\$this->set('bakeArticle', \$this->BakeArticle->find('first', \$options));", $result);
$this->assertContains('function add()', $result);
$this->assertContains("if (\$this->request->is('post'))", $result);
$this->assertContains('if ($this->BakeArticle->save($this->request->data))', $result);
$this->assertContains("\$this->Session->setFlash(__('The bake article has been saved'));", $result);
$this->assertContains('function edit($id = null)', $result);
$this->assertContains("\$this->Session->setFlash(__('The bake article could not be saved. Please, try again.'));", $result);
$this->assertContains('function delete($id = null)', $result);
$this->assertContains('if ($this->BakeArticle->delete())', $result);
$this->assertContains("\$this->Session->setFlash(__('Bake article deleted'));", $result);
$result = $this->Task->bakeActions('BakeArticles', 'admin_', true); $result = $this->Task->bakeActions('BakeArticles', 'admin_', true);
$this->assertContains('function admin_index() {', $result); $this->assertContains('function admin_index() {', $result);
$this->assertContains('function admin_add()', $result); $this->assertContains('function admin_add()', $result);
$this->assertContains('function admin_view($id = null)', $result); $this->assertContains('function admin_view($id = null)', $result);
@ -386,29 +354,8 @@ class ControllerTaskTest extends CakeTestCase {
*/ */
public function testBakeActionsWithNoSessions() { public function testBakeActionsWithNoSessions() {
$result = $this->Task->bakeActions('BakeArticles', null, false); $result = $this->Task->bakeActions('BakeArticles', null, false);
$expected = file_get_contents(CAKE . 'Test' . DS . 'bake_compare' . DS . 'Controller' . DS . 'ActionsWithNoSessions.ctp');
$this->assertContains('function index() {', $result); $this->assertTextEquals($expected, $result);
$this->assertContains('$this->BakeArticle->recursive = 0;', $result);
$this->assertContains("\$this->set('bakeArticles', \$this->Paginator->paginate());", $result);
$this->assertContains('function view($id = null)', $result);
$this->assertContains("throw new NotFoundException(__('Invalid bake article'));", $result);
$this->assertContains("\$this->set('bakeArticle', \$this->BakeArticle->find('first', \$options));", $result);
$this->assertContains('function add()', $result);
$this->assertContains("if (\$this->request->is('post'))", $result);
$this->assertContains('if ($this->BakeArticle->save($this->request->data))', $result);
$this->assertContains("\$this->flash(__('The bake article has been saved.'), array('action' => 'index'))", $result);
$this->assertContains('function edit($id = null)', $result);
$this->assertContains("\$this->BakeArticle->BakeTag->find('list')", $result);
$this->assertContains("\$this->set(compact('bakeTags'))", $result);
$this->assertContains('function delete($id = null)', $result);
$this->assertContains("\$this->request->onlyAllow('post', 'delete')", $result);
$this->assertContains('if ($this->BakeArticle->delete())', $result);
$this->assertContains("\$this->flash(__('Bake article deleted'), array('action' => 'index'))", $result);
} }
/** /**

View file

@ -193,7 +193,6 @@ class SomethingWithEmailComponent extends Component {
public $components = array('Email'); public $components = array('Email');
} }
/** /**
* ComponentTest class * ComponentTest class
* *

View file

@ -119,7 +119,6 @@ class MergePostsController extends MergeVarPluginAppController {
public $uses = array(); public $uses = array();
} }
/** /**
* Test Case for Controller Merging of Vars. * Test Case for Controller Merging of Vars.
* *

View file

@ -50,7 +50,6 @@ class ControllerTestAppController extends Controller {
public $components = array('Cookie'); public $components = array('Cookie');
} }
/** /**
* ControllerPost class * ControllerPost class
* *

View file

@ -131,7 +131,6 @@ class MyCustomExceptionRenderer extends ExceptionRenderer {
class MissingWidgetThingException extends NotFoundException { class MissingWidgetThingException extends NotFoundException {
} }
/** /**
* ExceptionRendererTest class * ExceptionRendererTest class
* *

View file

@ -1491,7 +1491,7 @@ class ModelIntegrationTest extends BaseModelTest {
'dynamicWith' => true, 'dynamicWith' => true,
'associationForeignKey' => 'join_b_id', 'associationForeignKey' => 'join_b_id',
'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '',
'finderQuery' => '', 'deleteQuery' => '', 'insertQuery' => '' 'finderQuery' => ''
)); ));
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
@ -1568,8 +1568,6 @@ class ModelIntegrationTest extends BaseModelTest {
'offset' => '', 'offset' => '',
'unique' => true, 'unique' => true,
'finderQuery' => '', 'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
)); ));
$this->assertSame($TestModel->hasAndBelongsToMany, $expected); $this->assertSame($TestModel->hasAndBelongsToMany, $expected);

View file

@ -588,7 +588,7 @@ class ModelValidationTest extends BaseModelTest {
$this->assertFalse($result, 'Save occurred even when with models failed. %s'); $this->assertFalse($result, 'Save occurred even when with models failed. %s');
$this->assertEquals($expectedError, $JoinThing->validationErrors); $this->assertEquals($expectedError, $JoinThing->validationErrors);
$count = $Something->find('count', array('conditions' => array('Something.id' => $data['Something']['id']))); $count = $Something->find('count', array('conditions' => array('Something.id' => $data['Something']['id'])));
$this->assertSame($count, 0); $this->assertSame(0, $count);
$data = array( $data = array(
'Something' => array( 'Something' => array(
@ -651,7 +651,7 @@ class ModelValidationTest extends BaseModelTest {
$this->assertEquals($expectedError, $JoinThing->validationErrors); $this->assertEquals($expectedError, $JoinThing->validationErrors);
$count = $Something->find('count', array('conditions' => array('Something.id' => $data['Something']['id']))); $count = $Something->find('count', array('conditions' => array('Something.id' => $data['Something']['id'])));
$this->assertSame($count, 0); $this->assertSame(0, $count);
$joinRecords = $JoinThing->find('count', array( $joinRecords = $JoinThing->find('count', array(
'conditions' => array('JoinThing.something_id' => $data['Something']['id']) 'conditions' => array('JoinThing.something_id' => $data['Something']['id'])
@ -692,11 +692,11 @@ class ModelValidationTest extends BaseModelTest {
$Author->create(); $Author->create();
$result = $Author->saveAll($data, array('validate' => 'first')); $result = $Author->saveAll($data, array('validate' => 'first'));
$this->assertTrue($result); $this->assertTrue($result);
$this->assertFalse(is_null($Author->id)); $this->assertNotNull($Author->id);
$id = $Author->id; $id = $Author->id;
$count = $Author->find('count', array('conditions' => array('Author.id' => $id))); $count = $Author->find('count', array('conditions' => array('Author.id' => $id)));
$this->assertSame($count, 1); $this->assertSame(1, $count);
$count = $Post->find('count', array( $count = $Post->find('count', array(
'conditions' => array('Post.author_id' => $id) 'conditions' => array('Post.author_id' => $id)
@ -2315,7 +2315,7 @@ class ModelValidationTest extends BaseModelTest {
), ),
), ),
); );
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
} }
/** /**
@ -2376,7 +2376,7 @@ class ModelValidationTest extends BaseModelTest {
), ),
), ),
); );
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
} }
} }

View file

@ -2517,7 +2517,6 @@ class MyCategoriesMyProduct extends CakeTestModel {
public $name = 'MyCategoriesMyProduct'; public $name = 'MyCategoriesMyProduct';
} }
/** /**
* NumberTree class * NumberTree class
* *

View file

@ -103,6 +103,22 @@ class RedirectRouteTest extends CakeTestCase {
$result = $route->parse('/my_controllers/do_something/passme/named:param'); $result = $route->parse('/my_controllers/do_something/passme/named:param');
$header = $route->response->header(); $header = $route->response->header();
$this->assertEquals(Router::url('/tags/add', true), $header['Location']); $this->assertEquals(Router::url('/tags/add', true), $header['Location']);
$route = new RedirectRoute('/:lang/my_controllers', array('controller' => 'tags', 'action' => 'add'), array('lang' => '(nl|en)', 'persist' => array('lang')));
$route->stop = false;
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
$result = $route->parse('/nl/my_controllers/');
$header = $route->response->header();
$this->assertEquals(Router::url('/tags/add/lang:nl', true), $header['Location']);
Router::$routes = array(); // reset default routes
Router::connect('/:lang/preferred_controllers', array('controller' => 'tags', 'action' => 'add'), array('lang' => '(nl|en)', 'persist' => array('lang')));
$route = new RedirectRoute('/:lang/my_controllers', array('controller' => 'tags', 'action' => 'add'), array('lang' => '(nl|en)', 'persist' => array('lang')));
$route->stop = false;
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
$result = $route->parse('/nl/my_controllers/');
$header = $route->response->header();
$this->assertEquals(Router::url('/nl/preferred_controllers', true), $header['Location']);
} }
} }

View file

@ -111,7 +111,6 @@ class StringsTestFixture extends CakeTestFixture {
); );
} }
/** /**
* CakeTestFixtureImportFixture class * CakeTestFixtureImportFixture class
* *
@ -175,7 +174,6 @@ class FixturePrefixTest extends Model {
public $useDbConfig = 'test'; public $useDbConfig = 'test';
} }
/** /**
* Test case for CakeTestFixture * Test case for CakeTestFixture
* *

View file

@ -210,6 +210,28 @@ class ControllerTestCaseTest extends CakeTestCase {
$this->assertEquals('written!', $Posts->Auth->Session->write('something')); $this->assertEquals('written!', $Posts->Auth->Session->write('something'));
} }
/**
* testGenerateWithComponentConfig
*/
public function testGenerateWithComponentConfig() {
$Tests = $this->Case->generate('TestConfigs', array(
));
$expected = array('some' => 'config');
$settings = array_intersect_key($Tests->RequestHandler->settings, array('some' => 'foo'));
$this->assertSame($expected, $settings, 'A mocked component should have the same config as an unmocked component');
$Tests = $this->Case->generate('TestConfigs', array(
'components' => array(
'RequestHandler' => array('isPut')
)
));
$expected = array('some' => 'config');
$settings = array_intersect_key($Tests->RequestHandler->settings, array('some' => 'foo'));
$this->assertSame($expected, $settings, 'A mocked component should have the same config as an unmocked component');
}
/** /**
* Tests ControllerTestCase::generate() using classes from plugins * Tests ControllerTestCase::generate() using classes from plugins
*/ */

View file

@ -217,19 +217,19 @@ class FileTest extends CakeTestCase {
$this->assertTrue(is_resource($this->File->handle)); $this->assertTrue(is_resource($this->File->handle));
$result = $this->File->offset(); $result = $this->File->offset();
$expecting = 0; $expected = 0;
$this->assertSame($result, $expecting); $this->assertSame($expected, $result);
$data = file_get_contents(__FILE__); $data = file_get_contents(__FILE__);
$success = $this->File->offset(5); $success = $this->File->offset(5);
$expecting = substr($data, 5, 3); $expected = substr($data, 5, 3);
$result = $this->File->read(3); $result = $this->File->read(3);
$this->assertTrue($success); $this->assertTrue($success);
$this->assertEquals($expecting, $result); $this->assertEquals($expected, $result);
$result = $this->File->offset(); $result = $this->File->offset();
$expecting = 5 + 3; $expected = 5 + 3;
$this->assertSame($result, $expecting); $this->assertSame($expected, $result);
} }
/** /**

View file

@ -1042,7 +1042,7 @@ class HashTest extends CakeTestCase {
1 => array('Person' => array('name' => 'Jeff')), 1 => array('Person' => array('name' => 'Jeff')),
); );
$a = Hash::sort($a, '{n}.Person.name', 'ASC', 'STRING'); $a = Hash::sort($a, '{n}.Person.name', 'ASC', 'STRING');
$this->assertEquals($a, $b); $this->assertSame($a, $b);
$names = array( $names = array(
array('employees' => array( array('employees' => array(
@ -1065,7 +1065,38 @@ class HashTest extends CakeTestCase {
array('employees' => array(array('name' => array()))), array('employees' => array(array('name' => array()))),
array('employees' => array(array('name' => array()))) array('employees' => array(array('name' => array())))
); );
$this->assertEquals($expected, $result); $this->assertSame($expected, $result);
$a = array(
'SU' => array(
'total_fulfillable' => 2
),
'AA' => array(
'total_fulfillable' => 1
),
'LX' => array(
'total_fulfillable' => 0
),
'BL' => array(
'total_fulfillable' => 3
),
);
$expected = array(
'LX' => array(
'total_fulfillable' => 0
),
'AA' => array(
'total_fulfillable' => 1
),
'SU' => array(
'total_fulfillable' => 2
),
'BL' => array(
'total_fulfillable' => 3
),
);
$result = Hash::sort($a, '{s}.total_fulfillable', 'asc');
$this->assertSame($expected, $result);
} }
/** /**
@ -2209,7 +2240,7 @@ class HashTest extends CakeTestCase {
) )
) )
); );
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$data = array('a.b.100.a' => null, 'a.b.200.a' => null); $data = array('a.b.100.a' => null, 'a.b.200.a' => null);
$expected = array( $expected = array(

View file

@ -7078,6 +7078,23 @@ class FormHelperTest extends CakeTestCase {
'Delete', 'Delete',
'/a' '/a'
)); ));
$result = $this->Form->postLink(
'',
array('controller' => 'items', 'action' => 'delete', 10),
array('class' => 'btn btn-danger', 'escape' => false),
'Confirm thing'
);
$this->assertTags($result, array(
'form' => array(
'method' => 'post', 'action' => '/items/delete/10',
'name' => 'preg:/post_\w+/', 'id' => 'preg:/post_\w+/', 'style' => 'display:none;'
),
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
'/form',
'a' => array('class' => 'btn btn-danger', 'href' => '#', 'onclick' => 'preg:/if \(confirm\(\'Confirm thing\'\)\) \{ document\.post_\w+\.submit\(\); \} event\.returnValue = false; return false;/'),
'/a'
));
} }
/** /**

View file

@ -219,7 +219,6 @@ class TestAfterHelper extends Helper {
} }
/** /**
* ViewTest class * ViewTest class
* *

View file

@ -0,0 +1,91 @@
/**
* index method
*
* @return void
*/
public function index() {
$this->BakeArticle->recursive = 0;
$this->set('bakeArticles', $this->Paginator->paginate());
}
/**
* view method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function view($id = null) {
if (!$this->BakeArticle->exists($id)) {
throw new NotFoundException(__('Invalid bake article'));
}
$options = array('conditions' => array('BakeArticle.' . $this->BakeArticle->primaryKey => $id));
$this->set('bakeArticle', $this->BakeArticle->find('first', $options));
}
/**
* add method
*
* @return void
*/
public function add() {
if ($this->request->is('post')) {
$this->BakeArticle->create();
if ($this->BakeArticle->save($this->request->data)) {
$this->Session->setFlash(__('The bake article has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The bake article could not be saved. Please, try again.'));
}
}
$bakeTags = $this->BakeArticle->BakeTag->find('list');
$this->set(compact('bakeTags'));
}
/**
* edit method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function edit($id = null) {
if (!$this->BakeArticle->exists($id)) {
throw new NotFoundException(__('Invalid bake article'));
}
if ($this->request->is('post') || $this->request->is('put')) {
if ($this->BakeArticle->save($this->request->data)) {
$this->Session->setFlash(__('The bake article has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The bake article could not be saved. Please, try again.'));
}
} else {
$options = array('conditions' => array('BakeArticle.' . $this->BakeArticle->primaryKey => $id));
$this->request->data = $this->BakeArticle->find('first', $options);
}
$bakeTags = $this->BakeArticle->BakeTag->find('list');
$this->set(compact('bakeTags'));
}
/**
* delete method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function delete($id = null) {
$this->BakeArticle->id = $id;
if (!$this->BakeArticle->exists()) {
throw new NotFoundException(__('Invalid bake article'));
}
$this->request->onlyAllow('post', 'delete');
if ($this->BakeArticle->delete()) {
$this->Session->setFlash(__('The bake article has been deleted.'));
} else {
$this->Session->setFlash(__('The bake article could not be deleted. Please, try again.'));
}
return $this->redirect(array('action' => 'index'));
}

View file

@ -0,0 +1,84 @@
/**
* index method
*
* @return void
*/
public function index() {
$this->BakeArticle->recursive = 0;
$this->set('bakeArticles', $this->Paginator->paginate());
}
/**
* view method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function view($id = null) {
if (!$this->BakeArticle->exists($id)) {
throw new NotFoundException(__('Invalid bake article'));
}
$options = array('conditions' => array('BakeArticle.' . $this->BakeArticle->primaryKey => $id));
$this->set('bakeArticle', $this->BakeArticle->find('first', $options));
}
/**
* add method
*
* @return void
*/
public function add() {
if ($this->request->is('post')) {
$this->BakeArticle->create();
if ($this->BakeArticle->save($this->request->data)) {
return $this->flash(__('The bake article has been saved.'), array('action' => 'index'));
}
}
$bakeTags = $this->BakeArticle->BakeTag->find('list');
$this->set(compact('bakeTags'));
}
/**
* edit method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function edit($id = null) {
if (!$this->BakeArticle->exists($id)) {
throw new NotFoundException(__('Invalid bake article'));
}
if ($this->request->is('post') || $this->request->is('put')) {
if ($this->BakeArticle->save($this->request->data)) {
return $this->flash(__('The bake article has been saved.'), array('action' => 'index'));
}
} else {
$options = array('conditions' => array('BakeArticle.' . $this->BakeArticle->primaryKey => $id));
$this->request->data = $this->BakeArticle->find('first', $options);
}
$bakeTags = $this->BakeArticle->BakeTag->find('list');
$this->set(compact('bakeTags'));
}
/**
* delete method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function delete($id = null) {
$this->BakeArticle->id = $id;
if (!$this->BakeArticle->exists()) {
throw new NotFoundException(__('Invalid bake article'));
}
$this->request->onlyAllow('post', 'delete');
if ($this->BakeArticle->delete()) {
return $this->flash(__('The bake article has been deleted.'), array('action' => 'index'));
} else {
return $this->flash(__('The bake article could not be deleted. Please, try again.'), array('action' => 'index'));
}
}

View file

@ -0,0 +1,27 @@
<?php
App::uses('AppController', 'Controller');
/**
* Articles Controller
*
* @property Article $Article
* @property AclComponent $Acl
* @property AuthComponent $Auth
* @property PaginatorComponent $Paginator
*/
class ArticlesController extends AppController {
/**
* Helpers
*
* @var array
*/
public $helpers = array('Js', 'Time');
/**
* Components
*
* @var array
*/
public $components = array('Acl', 'Auth', 'Paginator');
}

View file

@ -0,0 +1,18 @@
<?php
App::uses('AppController', 'Controller');
/**
* Articles Controller
*
* @property Article $Article
* @property PaginatorComponent $Paginator
*/
class ArticlesController extends AppController {
/**
* Components
*
* @var array
*/
public $components = array('Paginator');
}

View file

@ -0,0 +1,16 @@
<?php
App::uses('AppController', 'Controller');
/**
* Articles Controller
*
*/
class ArticlesController extends AppController {
/**
* Scaffold
*
* @var mixed
*/
public $scaffold;
}

View file

@ -0,0 +1,13 @@
<?php
App::uses('CakeErrorController', 'Controller');
class TestConfigsController extends CakeErrorController {
public $components = array(
'RequestHandler' => array(
'some' => 'config'
)
);
}

View file

@ -364,7 +364,8 @@ abstract class ControllerTestCase extends CakeTestCase {
'class' => $componentClass 'class' => $componentClass
)); ));
} }
$componentObj = $this->getMock($componentClass, $methods, array($controllerObj->Components)); $config = isset($controllerObj->components[$component]) ? $controllerObj->components[$component] : array();
$componentObj = $this->getMock($componentClass, $methods, array($controllerObj->Components, $config));
$controllerObj->Components->set($name, $componentObj); $controllerObj->Components->set($name, $componentObj);
$controllerObj->Components->enable($name); $controllerObj->Components->enable($name);
} }

View file

@ -248,7 +248,7 @@ class CakeTime {
*/ */
public static function convert($serverTime, $timezone) { public static function convert($serverTime, $timezone) {
static $serverTimezone = null; static $serverTimezone = null;
if (is_null($serverTimezone) || (date_default_timezone_get() !== $serverTimezone->getName())) { if ($serverTimezone === null || (date_default_timezone_get() !== $serverTimezone->getName())) {
$serverTimezone = new DateTimeZone(date_default_timezone_get()); $serverTimezone = new DateTimeZone(date_default_timezone_get());
} }
$serverOffset = $serverTimezone->getOffset(new DateTime('@' . $serverTime)); $serverOffset = $serverTimezone->getOffset(new DateTime('@' . $serverTime));
@ -673,7 +673,7 @@ class CakeTime {
public static function toRSS($dateString, $timezone = null) { public static function toRSS($dateString, $timezone = null) {
$date = self::fromString($dateString, $timezone); $date = self::fromString($dateString, $timezone);
if (is_null($timezone)) { if ($timezone === null) {
return date("r", $date); return date("r", $date);
} }

View file

@ -289,7 +289,7 @@ class ClassRegistry {
if (empty($param) && is_array($type)) { if (empty($param) && is_array($type)) {
$param = $type; $param = $type;
$type = 'Model'; $type = 'Model';
} elseif (is_null($param)) { } elseif ($param === null) {
unset($_this->_config[$type]); unset($_this->_config[$type]);
} elseif (empty($param) && is_string($type)) { } elseif (empty($param) && is_string($type)) {
return isset($_this->_config[$type]) ? $_this->_config[$type] : null; return isset($_this->_config[$type]) ? $_this->_config[$type] : null;

View file

@ -706,7 +706,7 @@ class Debugger {
$self = Debugger::getInstance(); $self = Debugger::getInstance();
$data = null; $data = null;
if (is_null($format)) { if ($format === null) {
return Debugger::outputAs(); return Debugger::outputAs();
} }
@ -815,7 +815,7 @@ class Debugger {
if (is_object($var)) { if (is_object($var)) {
return get_class($var); return get_class($var);
} }
if (is_null($var)) { if ($var === null) {
return 'null'; return 'null';
} }
if (is_string($var)) { if (is_string($var)) {
@ -846,11 +846,11 @@ class Debugger {
*/ */
public static function checkSecurityKeys() { public static function checkSecurityKeys() {
if (Configure::read('Security.salt') === 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi') { if (Configure::read('Security.salt') === 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi') {
trigger_error(__d('cake_dev', 'Please change the value of \'Security.salt\' in app/Config/core.php to a salt value specific to your application'), E_USER_NOTICE); trigger_error(__d('cake_dev', 'Please change the value of %s in %s to a salt value specific to your application.', '\'Security.salt\'', 'APP/Config/core.php'), E_USER_NOTICE);
} }
if (Configure::read('Security.cipherSeed') === '76859309657453542496749683645') { if (Configure::read('Security.cipherSeed') === '76859309657453542496749683645') {
trigger_error(__d('cake_dev', 'Please change the value of \'Security.cipherSeed\' in app/Config/core.php to a numeric (digits only) seed value specific to your application'), E_USER_NOTICE); trigger_error(__d('cake_dev', 'Please change the value of %s in %s to a numeric (digits only) seed value specific to your application.', '\'Security.cipherSeed\'', 'APP/Config/core.php'), E_USER_NOTICE);
} }
} }

View file

@ -395,7 +395,7 @@ class File {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::pwd * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::pwd
*/ */
public function pwd() { public function pwd() {
if (is_null($this->path)) { if ($this->path === null) {
$this->path = $this->Folder->slashTerm($this->Folder->pwd()) . $this->name; $this->path = $this->Folder->slashTerm($this->Folder->pwd()) . $this->name;
} }
return $this->path; return $this->path;

View file

@ -816,7 +816,7 @@ class Hash {
$stack = array(); $stack = array();
foreach ($data as $k => $r) { foreach ($data as $k => $r) {
$id = $k; $id = $k;
if (!is_null($key)) { if ($key !== null) {
$id = $key; $id = $key;
} }
if (is_array($r) && !empty($r)) { if (is_array($r) && !empty($r)) {

View file

@ -225,7 +225,7 @@ abstract class ObjectCollection {
} }
foreach ($name as $object => $objectPriority) { foreach ($name as $object => $objectPriority) {
if (isset($this->_loaded[$object])) { if (isset($this->_loaded[$object])) {
if (is_null($objectPriority)) { if ($objectPriority === null) {
$objectPriority = $this->defaultPriority; $objectPriority = $this->defaultPriority;
} }
$this->_loaded[$object]->settings['priority'] = $objectPriority; $this->_loaded[$object]->settings['priority'] = $objectPriority;

View file

@ -935,7 +935,7 @@ class Set {
$stack = array(); $stack = array();
foreach ($results as $k => $r) { foreach ($results as $k => $r) {
$id = $k; $id = $k;
if (!is_null($key)) { if ($key !== null) {
$id = $key; $id = $key;
} }
if (is_array($r) && !empty($r)) { if (is_array($r) && !empty($r)) {

View file

@ -149,7 +149,7 @@ class Validation {
return false; return false;
} }
if (!is_null($regex)) { if ($regex !== null) {
if (self::_check($check, $regex)) { if (self::_check($check, $regex)) {
return self::luhn($check, $deep); return self::luhn($check, $deep);
} }
@ -254,7 +254,7 @@ class Validation {
} }
break; break;
default: default:
self::$errors[] = __d('cake_dev', 'You must define the $operator parameter for Validation::comparison()'); self::$errors[] = __d('cake_dev', 'You must define the $operator parameter for %s', 'Validation::comparison()');
} }
return false; return false;
} }
@ -272,7 +272,7 @@ class Validation {
extract(self::_defaults($check)); extract(self::_defaults($check));
} }
if ($regex === null) { if ($regex === null) {
self::$errors[] = __d('cake_dev', 'You must define a regular expression for Validation::custom()'); self::$errors[] = __d('cake_dev', 'You must define a regular expression for %s', 'Validation::custom()');
return false; return false;
} }
return self::_check($check, $regex); return self::_check($check, $regex);
@ -297,7 +297,7 @@ class Validation {
* @return boolean Success * @return boolean Success
*/ */
public static function date($check, $format = 'ymd', $regex = null) { public static function date($check, $format = 'ymd', $regex = null) {
if (!is_null($regex)) { if ($regex !== null) {
return self::_check($check, $regex); return self::_check($check, $regex);
} }
@ -390,7 +390,7 @@ class Validation {
* @return boolean Success * @return boolean Success
*/ */
public static function decimal($check, $places = null, $regex = null) { public static function decimal($check, $places = null, $regex = null) {
if (is_null($regex)) { if ($regex === null) {
$lnum = '[0-9]+'; $lnum = '[0-9]+';
$dnum = "[0-9]*[\.]{$lnum}"; $dnum = "[0-9]*[\.]{$lnum}";
$sign = '[+-]?'; $sign = '[+-]?';
@ -430,7 +430,7 @@ class Validation {
extract(self::_defaults($check)); extract(self::_defaults($check));
} }
if (is_null($regex)) { if ($regex === null) {
$regex = '/^[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . self::$_pattern['hostname'] . '$/i'; $regex = '/^[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . self::$_pattern['hostname'] . '$/i';
} }
$return = self::_check($check, $regex); $return = self::_check($check, $regex);
@ -612,7 +612,7 @@ class Validation {
extract(self::_defaults($check)); extract(self::_defaults($check));
} }
if (is_null($regex)) { if ($regex === null) {
switch ($country) { switch ($country) {
case 'us': case 'us':
case 'ca': case 'ca':
@ -649,7 +649,7 @@ class Validation {
extract(self::_defaults($check)); extract(self::_defaults($check));
} }
if (is_null($regex)) { if ($regex === null) {
switch ($country) { switch ($country) {
case 'uk': case 'uk':
$regex = '/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]? [0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i'; $regex = '/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]? [0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i';
@ -710,7 +710,7 @@ class Validation {
extract(self::_defaults($check)); extract(self::_defaults($check));
} }
if (is_null($regex)) { if ($regex === null) {
switch ($country) { switch ($country) {
case 'dk': case 'dk':
$regex = '/\\A\\b[0-9]{6}-[0-9]{4}\\b\\z/i'; $regex = '/\\A\\b[0-9]{6}-[0-9]{4}\\b\\z/i';

View file

@ -315,7 +315,7 @@ class Xml {
} }
$child = $dom->createElement($key); $child = $dom->createElement($key);
if (!is_null($childValue)) { if ($childValue !== null) {
$child->appendChild($dom->createTextNode($childValue)); $child->appendChild($dom->createTextNode($childValue));
} }
if ($childNS) { if ($childNS) {

View file

@ -2884,7 +2884,7 @@ class FormHelper extends AppHelper {
* @return array inputDefaults * @return array inputDefaults
*/ */
public function inputDefaults($defaults = null, $merge = false) { public function inputDefaults($defaults = null, $merge = false) {
if (!is_null($defaults)) { if ($defaults !== null) {
if ($merge) { if ($merge) {
$this->_inputDefaults = array_merge($this->_inputDefaults, (array)$defaults); $this->_inputDefaults = array_merge($this->_inputDefaults, (array)$defaults);
} else { } else {

View file

@ -308,7 +308,7 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
public function drop($options = array()) { public function drop($options = array()) {
if (empty($options['drag'])) { if (empty($options['drag'])) {
trigger_error( trigger_error(
__d('cake_dev', 'MootoolsEngine::drop() requires a "drag" option to properly function'), E_USER_WARNING __d('cake_dev', '%s requires a "drag" option to properly function'), 'MootoolsEngine::drop()', E_USER_WARNING
); );
return false; return false;
} }

View file

@ -96,7 +96,7 @@ class PaginatorHelper extends AppHelper {
$classname = $ajaxProvider . 'Helper'; $classname = $ajaxProvider . 'Helper';
if (!class_exists($classname) || !method_exists($classname, 'link')) { if (!class_exists($classname) || !method_exists($classname, 'link')) {
throw new CakeException( throw new CakeException(
__d('cake_dev', '%s does not implement a link() method, it is incompatible with PaginatorHelper', $classname) __d('cake_dev', '%s does not implement a %s method, it is incompatible with %s', $classname, 'link()', 'PaginatorHelper')
); );
} }
parent::__construct($View, $settings); parent::__construct($View, $settings);

View file

@ -260,7 +260,7 @@ class RssHelper extends AppHelper {
default: default:
$attrib = $att; $attrib = $att;
} }
if (!is_null($val) && $escape) { if ($val !== null && $escape) {
$val = h($val); $val = h($val);
} }
$elements[$key] = $this->elem($key, $attrib, $val); $elements[$key] = $this->elem($key, $attrib, $val);

View file

@ -58,7 +58,7 @@ class ScaffoldView extends View {
$scaffoldAction = 'scaffold.' . $name; $scaffoldAction = 'scaffold.' . $name;
if (!is_null($this->subDir)) { if ($this->subDir !== null) {
$subDir = strtolower($this->subDir) . DS; $subDir = strtolower($this->subDir) . DS;
} else { } else {
$subDir = null; $subDir = null;

View file

@ -972,7 +972,7 @@ class View extends Object {
protected function _getViewFileName($name = null) { protected function _getViewFileName($name = null) {
$subDir = null; $subDir = null;
if (!is_null($this->subDir)) { if ($this->subDir !== null) {
$subDir = $this->subDir . DS; $subDir = $this->subDir . DS;
} }
@ -1054,7 +1054,7 @@ class View extends Object {
} }
$subDir = null; $subDir = null;
if (!is_null($this->layoutPath)) { if ($this->layoutPath !== null) {
$subDir = $this->layoutPath . DS; $subDir = $this->layoutPath . DS;
} }
list($plugin, $name) = $this->pluginSplit($name); list($plugin, $name) = $this->pluginSplit($name);