Merge branch 'master' into 2.4

Conflicts:
	lib/Cake/Test/Case/Network/CakeRequestTest.php
This commit is contained in:
mark_story 2013-07-03 14:21:09 -04:00
commit c597855fe4
59 changed files with 484 additions and 421 deletions

View file

@ -82,7 +82,7 @@ class AclShell extends AppShell {
$out .= __d('cake_console', 'Current ACL Classname: %s', $class) . "\n"; $out .= __d('cake_console', 'Current ACL Classname: %s', $class) . "\n";
$out .= "--------------------------------------------------\n"; $out .= "--------------------------------------------------\n";
$this->err($out); $this->err($out);
$this->_stop(); return $this->_stop();
} }
if ($this->command) { if ($this->command) {

View file

@ -100,7 +100,7 @@ class ApiShell extends AppShell {
if (isset($this->params['method'])) { if (isset($this->params['method'])) {
if (!isset($parsed[$this->params['method']])) { if (!isset($parsed[$this->params['method']])) {
$this->err(__d('cake_console', '%s::%s() could not be found', $class, $this->params['method'])); $this->err(__d('cake_console', '%s::%s() could not be found', $class, $this->params['method']));
$this->_stop(); return $this->_stop();
} }
$method = $parsed[$this->params['method']]; $method = $parsed[$this->params['method']];
$this->out($class . '::' . $method['method'] . $method['parameters']); $this->out($class . '::' . $method['method'] . $method['parameters']);

View file

@ -123,8 +123,7 @@ class BakeShell extends AppShell {
$this->Test->execute(); $this->Test->execute();
break; break;
case 'Q': case 'Q':
exit(0); return $this->_stop();
break;
default: default:
$this->out(__d('cake_console', 'You have made an invalid selection. Please choose a type of class to Bake by entering D, M, V, F, T, or C.')); $this->out(__d('cake_console', 'You have made an invalid selection. Please choose a type of class to Bake by entering D, M, V, F, T, or C.'));
} }

View file

@ -172,7 +172,7 @@ class ConsoleShell extends AppShell {
switch ($command) { switch ($command) {
case 'help': case 'help':
$this->help(); $this->help();
break; break;
case 'quit': case 'quit':
case 'exit': case 'exit':
return true; return true;
@ -182,7 +182,7 @@ class ConsoleShell extends AppShell {
foreach ($this->models as $model) { foreach ($this->models as $model) {
$this->out(" - {$model}"); $this->out(" - {$model}");
} }
break; break;
case preg_match("/^(\w+) bind (\w+) (\w+)/", $command, $tmp): case preg_match("/^(\w+) bind (\w+) (\w+)/", $command, $tmp):
foreach ($tmp as $data) { foreach ($tmp as $data) {
$data = strip_tags($data); $data = strip_tags($data);
@ -200,7 +200,7 @@ class ConsoleShell extends AppShell {
} else { } else {
$this->out(__d('cake_console', "Please verify you are using valid models and association types")); $this->out(__d('cake_console', "Please verify you are using valid models and association types"));
} }
break; break;
case preg_match("/^(\w+) unbind (\w+) (\w+)/", $command, $tmp): case preg_match("/^(\w+) unbind (\w+) (\w+)/", $command, $tmp):
foreach ($tmp as $data) { foreach ($tmp as $data) {
$data = strip_tags($data); $data = strip_tags($data);
@ -228,7 +228,7 @@ class ConsoleShell extends AppShell {
} else { } else {
$this->out(__d('cake_console', "Please verify you are using valid models, valid current association, and valid association types")); $this->out(__d('cake_console', "Please verify you are using valid models, valid current association, and valid association types"));
} }
break; break;
case (strpos($command, "->find") > 0): case (strpos($command, "->find") > 0):
// Remove any bad info // Remove any bad info
$command = strip_tags($command); $command = strip_tags($command);
@ -285,7 +285,7 @@ class ConsoleShell extends AppShell {
$this->out(__d('cake_console', "%s is not a valid model", $modelToCheck)); $this->out(__d('cake_console', "%s is not a valid model", $modelToCheck));
} }
break; break;
case (strpos($command, '->save') > 0): case (strpos($command, '->save') > 0):
// Validate the model we're trying to save here // Validate the model we're trying to save here
$command = strip_tags($command); $command = strip_tags($command);
@ -302,7 +302,7 @@ class ConsoleShell extends AppShell {
//@codingStandardsIgnoreEnd //@codingStandardsIgnoreEnd
$this->out(__d('cake_console', 'Saved record for %s', $modelToSave)); $this->out(__d('cake_console', 'Saved record for %s', $modelToSave));
} }
break; break;
case preg_match("/^(\w+) columns/", $command, $tmp): case preg_match("/^(\w+) columns/", $command, $tmp):
$modelToCheck = strip_tags(str_replace($this->badCommandChars, "", $tmp[1])); $modelToCheck = strip_tags(str_replace($this->badCommandChars, "", $tmp[1]));
@ -321,31 +321,30 @@ class ConsoleShell extends AppShell {
} else { } else {
$this->out(__d('cake_console', "Please verify that you selected a valid model")); $this->out(__d('cake_console', "Please verify that you selected a valid model"));
} }
break; break;
case preg_match("/^routes\s+reload/i", $command, $tmp): case preg_match("/^routes\s+reload/i", $command, $tmp):
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.")); $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; 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)));
break; break;
case preg_match("/^routes\s+show/i", $command, $tmp): case preg_match("/^routes\s+show/i", $command, $tmp):
$this->out(print_r(Hash::combine(Router::$routes, '{n}.template', '{n}.defaults'), true)); $this->out(print_r(Hash::combine(Router::$routes, '{n}.template', '{n}.defaults'), true));
break; break;
case (preg_match("/^route\s+(\(.*\))$/i", $command, $tmp) == true): case (preg_match("/^route\s+(\(.*\))$/i", $command, $tmp) == true):
//@codingStandardsIgnoreStart //@codingStandardsIgnoreStart
if ($url = eval('return array' . $tmp[1] . ';')) { if ($url = eval('return array' . $tmp[1] . ';')) {
//@codingStandardsIgnoreEnd //@codingStandardsIgnoreEnd
$this->out(Router::url($url)); $this->out(Router::url($url));
} }
break; break;
case preg_match("/^route\s+(.*)/i", $command, $tmp): case preg_match("/^route\s+(.*)/i", $command, $tmp):
$this->out(var_export(Router::parse($tmp[1]), true)); $this->out(var_export(Router::parse($tmp[1]), true));
break; break;
default: default:
$this->out(__d('cake_console', "Invalid command")); $this->out(__d('cake_console', "Invalid command"));
$this->out(); $this->out();
break;
} }
$command = ''; $command = '';
} }

View file

@ -76,16 +76,15 @@ class I18nShell extends AppShell {
switch ($choice) { switch ($choice) {
case 'e': case 'e':
$this->Extract->execute(); $this->Extract->execute();
break; break;
case 'i': case 'i':
$this->initdb(); $this->initdb();
break; break;
case 'h': case 'h':
$this->out($this->OptionParser->help()); $this->out($this->OptionParser->help());
break; break;
case 'q': case 'q':
exit(0); return $this->_stop();
break;
default: default:
$this->out(__d('cake_console', 'You have made an invalid selection. Please choose a command to execute by entering E, I, H, or Q.')); $this->out(__d('cake_console', 'You have made an invalid selection. Please choose a command to execute by entering E, I, H, or Q.'));
} }

View file

@ -106,12 +106,11 @@ class SchemaShell extends AppShell {
$File = new File($this->Schema->path . DS . $this->params['file']); $File = new File($this->Schema->path . DS . $this->params['file']);
if ($File->exists()) { if ($File->exists()) {
$this->out($File->read()); $this->out($File->read());
$this->_stop(); return $this->_stop();
} else {
$file = $this->Schema->path . DS . $this->params['file'];
$this->err(__d('cake_console', 'Schema file (%s) could not be found.', $file));
$this->_stop();
} }
$file = $this->Schema->path . DS . $this->params['file'];
$this->err(__d('cake_console', 'Schema file (%s) could not be found.', $file));
return $this->_stop();
} }
/** /**
@ -191,11 +190,10 @@ class SchemaShell extends AppShell {
if ($this->Schema->write($content)) { if ($this->Schema->write($content)) {
$this->out(__d('cake_console', 'Schema file: %s generated', $content['file'])); $this->out(__d('cake_console', 'Schema file: %s generated', $content['file']));
$this->_stop(); return $this->_stop();
} else {
$this->err(__d('cake_console', 'Schema file: %s generated'));
$this->_stop();
} }
$this->err(__d('cake_console', 'Schema file: %s generated'));
return $this->_stop();
} }
/** /**
@ -212,7 +210,7 @@ class SchemaShell extends AppShell {
$Schema = $this->Schema->load(); $Schema = $this->Schema->load();
if (!$Schema) { if (!$Schema) {
$this->err(__d('cake_console', 'Schema could not be loaded')); $this->err(__d('cake_console', 'Schema could not be loaded'));
$this->_stop(); return $this->_stop();
} }
if (!empty($this->params['write'])) { if (!empty($this->params['write'])) {
if ($this->params['write'] == 1) { if ($this->params['write'] == 1) {
@ -236,10 +234,10 @@ class SchemaShell extends AppShell {
if ($File->write($contents)) { if ($File->write($contents)) {
$this->out(__d('cake_console', 'SQL dump file created in %s', $File->pwd())); $this->out(__d('cake_console', 'SQL dump file created in %s', $File->pwd()));
$this->_stop(); return $this->_stop();
} else { } else {
$this->err(__d('cake_console', 'SQL dump could not be created')); $this->err(__d('cake_console', 'SQL dump could not be created'));
$this->_stop(); return $this->_stop();
} }
} }
$this->out($contents); $this->out($contents);
@ -297,7 +295,7 @@ class SchemaShell extends AppShell {
$this->err(__d('cake_console', 'The chosen schema could not be loaded. Attempted to load:')); $this->err(__d('cake_console', 'The chosen schema could not be loaded. Attempted to load:'));
$this->err(__d('cake_console', 'File: %s', $this->Schema->path . DS . $this->Schema->file)); $this->err(__d('cake_console', 'File: %s', $this->Schema->path . DS . $this->Schema->file));
$this->err(__d('cake_console', 'Name: %s', $this->Schema->name)); $this->err(__d('cake_console', 'Name: %s', $this->Schema->name));
$this->_stop(); return $this->_stop();
} }
$table = null; $table = null;
if (isset($this->args[1])) { if (isset($this->args[1])) {
@ -330,13 +328,13 @@ class SchemaShell extends AppShell {
} }
if (empty($drop) || empty($create)) { if (empty($drop) || empty($create)) {
$this->out(__d('cake_console', 'Schema is up to date.')); $this->out(__d('cake_console', 'Schema is up to date.'));
$this->_stop(); return $this->_stop();
} }
$this->out("\n" . __d('cake_console', 'The following table(s) will be dropped.')); $this->out("\n" . __d('cake_console', 'The following table(s) will be dropped.'));
$this->out(array_keys($drop)); $this->out(array_keys($drop));
if ('y' == $this->in(__d('cake_console', 'Are you sure you want to drop the table(s)?'), array('y', 'n'), 'n')) { if ($this->in(__d('cake_console', 'Are you sure you want to drop the table(s)?'), array('y', 'n'), 'n') === 'y') {
$this->out(__d('cake_console', 'Dropping table(s).')); $this->out(__d('cake_console', 'Dropping table(s).'));
$this->_run($drop, 'drop', $Schema); $this->_run($drop, 'drop', $Schema);
} }
@ -344,7 +342,7 @@ class SchemaShell extends AppShell {
$this->out("\n" . __d('cake_console', 'The following table(s) will be created.')); $this->out("\n" . __d('cake_console', 'The following table(s) will be created.'));
$this->out(array_keys($create)); $this->out(array_keys($create));
if ('y' == $this->in(__d('cake_console', 'Are you sure you want to create the table(s)?'), array('y', 'n'), 'y')) { if ($this->in(__d('cake_console', 'Are you sure you want to create the table(s)?'), array('y', 'n'), 'y') === 'y') {
$this->out(__d('cake_console', 'Creating table(s).')); $this->out(__d('cake_console', 'Creating table(s).'));
$this->_run($create, 'create', $Schema); $this->_run($create, 'create', $Schema);
} }
@ -390,12 +388,12 @@ class SchemaShell extends AppShell {
if (empty($contents)) { if (empty($contents)) {
$this->out(__d('cake_console', 'Schema is up to date.')); $this->out(__d('cake_console', 'Schema is up to date.'));
$this->_stop(); return $this->_stop();
} }
$this->out("\n" . __d('cake_console', 'The following statements will run.')); $this->out("\n" . __d('cake_console', 'The following statements will run.'));
$this->out(array_map('trim', $contents)); $this->out(array_map('trim', $contents));
if ('y' == $this->in(__d('cake_console', 'Are you sure you want to alter the tables?'), array('y', 'n'), 'n')) { if ($this->in(__d('cake_console', 'Are you sure you want to alter the tables?'), array('y', 'n'), 'n') === 'y') {
$this->out(); $this->out();
$this->out(__d('cake_console', 'Updating Database...')); $this->out(__d('cake_console', 'Updating Database...'));
$this->_run($contents, 'update', $Schema); $this->_run($contents, 'update', $Schema);

View file

@ -289,7 +289,7 @@ class ControllerTask extends BakeTask {
App::uses($modelImport, $plugin . 'Model'); App::uses($modelImport, $plugin . 'Model');
if (!class_exists($modelImport)) { if (!class_exists($modelImport)) {
$this->err(__d('cake_console', 'You must have a model for this class to build basic methods. Please try again.')); $this->err(__d('cake_console', 'You must have a model for this class to build basic methods. Please try again.'));
$this->_stop(); return $this->_stop();
} }
$modelObj = ClassRegistry::init($currentModelName); $modelObj = ClassRegistry::init($currentModelName);

View file

@ -77,7 +77,7 @@ class DbConfigTask extends AppShell {
public function execute() { public function execute() {
if (empty($this->args)) { if (empty($this->args)) {
$this->_interactive(); $this->_interactive();
$this->_stop(); return $this->_stop();
} }
} }

View file

@ -207,7 +207,7 @@ class ExtractTask extends AppShell {
$response = $this->in($message, null, rtrim($this->_paths[0], DS) . DS . 'Locale'); $response = $this->in($message, null, rtrim($this->_paths[0], DS) . DS . 'Locale');
if (strtoupper($response) === 'Q') { if (strtoupper($response) === 'Q') {
$this->out(__d('cake_console', 'Extract Aborted')); $this->out(__d('cake_console', 'Extract Aborted'));
$this->_stop(); return $this->_stop();
} elseif ($this->_isPathUsable($response)) { } elseif ($this->_isPathUsable($response)) {
$this->_output = $response . DS; $this->_output = $response . DS;
break; break;

View file

@ -325,7 +325,7 @@ class FixtureTask extends BakeTask {
case 'integer': case 'integer':
case 'float': case 'float':
$insert = $i + 1; $insert = $i + 1;
break; break;
case 'string': case 'string':
case 'binary': case 'binary':
$isPrimaryUuid = ( $isPrimaryUuid = (
@ -340,22 +340,22 @@ class FixtureTask extends BakeTask {
$insert = substr($insert, 0, (int)$fieldInfo['length'] - 2); $insert = substr($insert, 0, (int)$fieldInfo['length'] - 2);
} }
} }
break; break;
case 'timestamp': case 'timestamp':
$insert = time(); $insert = time();
break; break;
case 'datetime': case 'datetime':
$insert = date('Y-m-d H:i:s'); $insert = date('Y-m-d H:i:s');
break; break;
case 'date': case 'date':
$insert = date('Y-m-d'); $insert = date('Y-m-d');
break; break;
case 'time': case 'time':
$insert = date('H:i:s'); $insert = date('H:i:s');
break; break;
case 'boolean': case 'boolean':
$insert = 1; $insert = 1;
break; break;
case 'text': case 'text':
$insert = "Lorem ipsum dolor sit amet, aliquet feugiat."; $insert = "Lorem ipsum dolor sit amet, aliquet feugiat.";
$insert .= " Convallis morbi fringilla gravida,"; $insert .= " Convallis morbi fringilla gravida,";
@ -364,7 +364,7 @@ class FixtureTask extends BakeTask {
$insert .= " vestibulum massa neque ut et, id hendrerit sit,"; $insert .= " vestibulum massa neque ut et, id hendrerit sit,";
$insert .= " feugiat in taciti enim proin nibh, tempor dignissim, rhoncus"; $insert .= " feugiat in taciti enim proin nibh, tempor dignissim, rhoncus";
$insert .= " duis vestibulum nunc mattis convallis."; $insert .= " duis vestibulum nunc mattis convallis.";
break; break;
} }
$record[$field] = $insert; $record[$field] = $insert;
} }

View file

@ -681,7 +681,7 @@ class ModelTask extends BakeTask {
$prompt = "{$model->name} {$type} {$assoc['alias']}?"; $prompt = "{$model->name} {$type} {$assoc['alias']}?";
$response = $this->in($prompt, array('y', 'n'), 'y'); $response = $this->in($prompt, array('y', 'n'), 'y');
if ('n' == strtolower($response)) { if (strtolower($response) === 'n') {
unset($associations[$type][$i]); unset($associations[$type][$i]);
} elseif ($type === 'hasMany') { } elseif ($type === 'hasMany') {
unset($associations['hasOne'][$i]); unset($associations['hasOne'][$i]);
@ -938,7 +938,7 @@ class ModelTask extends BakeTask {
} }
if (empty($tables)) { if (empty($tables)) {
$this->err(__d('cake_console', 'Your database does not have any tables.')); $this->err(__d('cake_console', 'Your database does not have any tables.'));
$this->_stop(); return $this->_stop();
} }
return $tables; return $tables;
} }
@ -960,7 +960,7 @@ class ModelTask extends BakeTask {
if ($enteredModel === 'q') { if ($enteredModel === 'q') {
$this->out(__d('cake_console', 'Exit')); $this->out(__d('cake_console', 'Exit'));
$this->_stop(); return $this->_stop();
} }
if (!$enteredModel || intval($enteredModel) > count($this->_modelNames)) { if (!$enteredModel || intval($enteredModel) > count($this->_modelNames)) {

View file

@ -65,9 +65,8 @@ class PluginTask extends AppShell {
$this->out(__d('cake_console', 'Plugin: %s already exists, no action taken', $plugin)); $this->out(__d('cake_console', 'Plugin: %s already exists, no action taken', $plugin));
$this->out(__d('cake_console', 'Path: %s', $pluginPath)); $this->out(__d('cake_console', 'Path: %s', $pluginPath));
return false; return false;
} else {
$this->_interactive($plugin);
} }
$this->_interactive($plugin);
} else { } else {
return $this->_interactive(); return $this->_interactive();
} }

View file

@ -368,12 +368,9 @@ class ProjectTask extends AppShell {
if ($File->write($result)) { if ($File->write($result)) {
Configure::write('Routing.prefixes', array($name)); Configure::write('Routing.prefixes', array($name));
return true; return true;
} else {
return false;
} }
} else {
return false;
} }
return false;
} }
/** /**
@ -417,7 +414,7 @@ class ProjectTask extends AppShell {
$this->out(__d('cake_console', 'You need to enable %s in %s to use prefix routing.', $this->out(__d('cake_console', 'You need to enable %s in %s to use prefix routing.',
'Configure::write(\'Routing.prefixes\', array(\'admin\'))', 'Configure::write(\'Routing.prefixes\', array(\'admin\'))',
'/app/Config/core.php')); '/app/Config/core.php'));
$this->_stop(); return $this->_stop();
} }
return $admin . '_'; return $admin . '_';
} }

View file

@ -267,7 +267,7 @@ class ViewTask extends BakeTask {
if (!class_exists($controllerClassName)) { if (!class_exists($controllerClassName)) {
$file = $controllerClassName . '.php'; $file = $controllerClassName . '.php';
$this->err(__d('cake_console', "The file '%s' could not be found.\nIn order to bake a view, you'll need to first create the controller.", $file)); $this->err(__d('cake_console', "The file '%s' could not be found.\nIn order to bake a view, you'll need to first create the controller.", $file));
$this->_stop(); return $this->_stop();
} }
$controllerObj = new $controllerClassName(); $controllerObj = new $controllerClassName();
$controllerObj->plugin = $this->plugin; $controllerObj->plugin = $this->plugin;
@ -334,10 +334,9 @@ class ViewTask extends BakeTask {
$looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n'), 'y'); $looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n'), 'y');
if (strtolower($looksGood) === 'y') { if (strtolower($looksGood) === 'y') {
$this->bake($action, ' '); $this->bake($action, ' ');
$this->_stop(); return $this->_stop();
} else {
$this->out(__d('cake_console', 'Bake Aborted.'));
} }
$this->out(__d('cake_console', 'Bake Aborted.'));
} }
/** /**

View file

@ -60,7 +60,7 @@ class ConsoleErrorHandler {
$exception->getMessage(), $exception->getMessage(),
$exception->getTraceAsString() $exception->getTraceAsString()
)); ));
$this->_stop($exception->getCode() ? $exception->getCode() : 1); return $this->_stop($exception->getCode() ? $exception->getCode() : 1);
} }
/** /**
@ -88,7 +88,7 @@ class ConsoleErrorHandler {
} }
if ($log === LOG_ERR) { if ($log === LOG_ERR) {
$this->_stop(1); return $this->_stop(1);
} }
} }

View file

@ -547,7 +547,7 @@ class Shell extends Object {
$result = $this->stdin->read(); $result = $this->stdin->read();
if ($result === false) { if ($result === false) {
$this->_stop(1); return $this->_stop(1);
} }
$result = trim($result); $result = trim($result);
@ -661,7 +661,7 @@ class Shell extends Object {
if (!empty($message)) { if (!empty($message)) {
$this->err($message); $this->err($message);
} }
$this->_stop(1); return $this->_stop(1);
} }
/** /**
@ -699,7 +699,7 @@ class Shell extends Object {
if (strtolower($key) === 'q') { if (strtolower($key) === 'q') {
$this->out(__d('cake_console', '<error>Quitting</error>.'), 2); $this->out(__d('cake_console', '<error>Quitting</error>.'), 2);
$this->_stop(); return $this->_stop();
} elseif (strtolower($key) !== 'y') { } elseif (strtolower($key) !== 'y') {
$this->out(__d('cake_console', 'Skip `%s`', $path), 2); $this->out(__d('cake_console', 'Skip `%s`', $path), 2);
return false; return false;

View file

@ -65,7 +65,7 @@ class ShellDispatcher {
*/ */
public static function run($argv) { public static function run($argv) {
$dispatcher = new ShellDispatcher($argv); $dispatcher = new ShellDispatcher($argv);
$dispatcher->_stop($dispatcher->dispatch() === false ? 1 : 0); return $dispatcher->_stop($dispatcher->dispatch() === false ? 1 : 0);
} }
/** /**

View file

@ -61,7 +61,7 @@ class FormAuthenticate extends BaseAuthenticate {
/** /**
* Authenticates the identity contained in a request. Will use the `settings.userModel`, and `settings.fields` * Authenticates the identity contained in a request. Will use the `settings.userModel`, and `settings.fields`
* to find POST data that is used to find a matching record in the `settings.userModel`. Will return false if * to find POST data that is used to find a matching record in the `settings.userModel`. Will return false if
* there is no post data, either username or password is missing, of if the scope conditions have not been met. * there is no post data, either username or password is missing, or if the scope conditions have not been met.
* *
* @param CakeRequest $request The request that contains login information. * @param CakeRequest $request The request that contains login information.
* @param CakeResponse $response Unused response object. * @param CakeResponse $response Unused response object.

View file

@ -250,13 +250,11 @@ class Scaffold {
$success $success
); );
return $this->_sendMessage($message); return $this->_sendMessage($message);
} else {
return $this->controller->afterScaffoldSaveError($action);
}
} else {
if ($this->_validSession) {
$this->controller->Session->setFlash(__d('cake', 'Please correct errors below.'));
} }
return $this->controller->afterScaffoldSaveError($action);
}
if ($this->_validSession) {
$this->controller->Session->setFlash(__d('cake', 'Please correct errors below.'));
} }
} }
@ -309,14 +307,13 @@ class Scaffold {
if ($this->ScaffoldModel->delete()) { if ($this->ScaffoldModel->delete()) {
$message = __d('cake', 'The %1$s with id: %2$s has been deleted.', Inflector::humanize($this->modelClass), $id); $message = __d('cake', 'The %1$s with id: %2$s has been deleted.', Inflector::humanize($this->modelClass), $id);
return $this->_sendMessage($message); return $this->_sendMessage($message);
} else {
$message = __d('cake',
'There was an error deleting the %1$s with id: %2$s',
Inflector::humanize($this->modelClass),
$id
);
return $this->_sendMessage($message);
} }
$message = __d('cake',
'There was an error deleting the %1$s with id: %2$s',
Inflector::humanize($this->modelClass),
$id
);
return $this->_sendMessage($message);
} elseif ($this->controller->scaffoldError('delete') === false) { } elseif ($this->controller->scaffoldError('delete') === false) {
return $this->_scaffoldError(); return $this->_scaffoldError();
} }
@ -388,21 +385,21 @@ class Scaffold {
case 'index': case 'index':
case 'list': case 'list':
$this->_scaffoldIndex($request); $this->_scaffoldIndex($request);
break; break;
case 'view': case 'view':
$this->_scaffoldView($request); $this->_scaffoldView($request);
break; break;
case 'add': case 'add':
case 'create': case 'create':
$this->_scaffoldSave($request, 'add'); $this->_scaffoldSave($request, 'add');
break; break;
case 'edit': case 'edit':
case 'update': case 'update':
$this->_scaffoldSave($request, 'edit'); $this->_scaffoldSave($request, 'edit');
break; break;
case 'delete': case 'delete':
$this->_scaffoldDelete($request); $this->_scaffoldDelete($request);
break; break;
} }
} else { } else {
throw new MissingActionException(array( throw new MissingActionException(array(

View file

@ -535,6 +535,9 @@ class App {
if (!isset(self::$_classMap[$className])) { if (!isset(self::$_classMap[$className])) {
return false; return false;
} }
if (strpos($className, '..') !== false) {
return false;
}
$parts = explode('.', self::$_classMap[$className], 2); $parts = explode('.', self::$_classMap[$className], 2);
list($plugin, $package) = count($parts) > 1 ? $parts : array(null, current($parts)); list($plugin, $package) = count($parts) > 1 ? $parts : array(null, current($parts));

View file

@ -219,14 +219,13 @@ class ErrorHandler {
'path' => Debugger::trimPath($file) 'path' => Debugger::trimPath($file)
); );
return Debugger::getInstance()->outputError($data); return Debugger::getInstance()->outputError($data);
} else {
$message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']';
if (!empty($errorConfig['trace'])) {
$trace = Debugger::trace(array('start' => 1, 'format' => 'log'));
$message .= "\nTrace:\n" . $trace . "\n";
}
return CakeLog::write($log, $message);
} }
$message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']';
if (!empty($errorConfig['trace'])) {
$trace = Debugger::trace(array('start' => 1, 'format' => 'log'));
$message .= "\nTrace:\n" . $trace . "\n";
}
return CakeLog::write($log, $message);
} }
/** /**
@ -275,28 +274,28 @@ class ErrorHandler {
case E_USER_ERROR: case E_USER_ERROR:
$error = 'Fatal Error'; $error = 'Fatal Error';
$log = LOG_ERR; $log = LOG_ERR;
break; break;
case E_WARNING: case E_WARNING:
case E_USER_WARNING: case E_USER_WARNING:
case E_COMPILE_WARNING: case E_COMPILE_WARNING:
case E_RECOVERABLE_ERROR: case E_RECOVERABLE_ERROR:
$error = 'Warning'; $error = 'Warning';
$log = LOG_WARNING; $log = LOG_WARNING;
break; break;
case E_NOTICE: case E_NOTICE:
case E_USER_NOTICE: case E_USER_NOTICE:
$error = 'Notice'; $error = 'Notice';
$log = LOG_NOTICE; $log = LOG_NOTICE;
break; break;
case E_STRICT: case E_STRICT:
$error = 'Strict'; $error = 'Strict';
$log = LOG_NOTICE; $log = LOG_NOTICE;
break; break;
case E_DEPRECATED: case E_DEPRECATED:
case E_USER_DEPRECATED: case E_USER_DEPRECATED:
$error = 'Deprecated'; $error = 'Deprecated';
$log = LOG_NOTICE; $log = LOG_NOTICE;
break; break;
} }
return array($error, $log); return array($error, $log);
} }

View file

@ -822,17 +822,16 @@ class TreeBehavior extends ModelBehavior {
array($Model->escapeField() => $id) array($Model->escapeField() => $id)
); );
return $Model->delete($id); return $Model->delete($id);
} else {
$edge = $this->_getMax($Model, $scope, $right, $recursive);
if ($node[$right] == $edge) {
$edge = $edge - 2;
}
$Model->id = $id;
return $Model->save(
array($left => $edge + 1, $right => $edge + 2, $parent => null),
array('callbacks' => false, 'validate' => false)
);
} }
$edge = $this->_getMax($Model, $scope, $right, $recursive);
if ($node[$right] == $edge) {
$edge = $edge - 2;
}
$Model->id = $id;
return $Model->save(
array($left => $edge + 1, $right => $edge + 2, $parent => null),
array('callbacks' => false, 'validate' => false)
);
} }
/** /**

View file

@ -357,7 +357,7 @@ class DataSource extends Object {
} }
} }
$type = $model->getColumnType($model->primaryKey); $type = $model->getColumnType($model->primaryKey);
break; break;
case '{$__cakeForeignKey__$}': case '{$__cakeForeignKey__$}':
foreach ($model->associations() as $name) { foreach ($model->associations() as $name) {
foreach ($model->$name as $assocName => $assoc) { foreach ($model->$name as $assocName => $assoc) {
@ -389,7 +389,7 @@ class DataSource extends Object {
} }
} }
} }
break; break;
} }
if (empty($val) && $val !== '0') { if (empty($val) && $val !== '0') {
return false; return false;

View file

@ -200,17 +200,16 @@ class Mysql extends DboSource {
if (!$result) { if (!$result) {
$result->closeCursor(); $result->closeCursor();
return array(); return array();
} else {
$tables = array();
while ($line = $result->fetch(PDO::FETCH_NUM)) {
$tables[] = $line[0];
}
$result->closeCursor();
parent::listSources($tables);
return $tables;
} }
$tables = array();
while ($line = $result->fetch(PDO::FETCH_NUM)) {
$tables[] = $line[0];
}
$result->closeCursor();
parent::listSources($tables);
return $tables;
} }
/** /**
@ -521,13 +520,13 @@ class Mysql extends DboSource {
} }
$colList[] = $alter; $colList[] = $alter;
} }
break; break;
case 'drop': case 'drop':
foreach ($column as $field => $col) { foreach ($column as $field => $col) {
$col['name'] = $field; $col['name'] = $field;
$colList[] = 'DROP ' . $this->name($field); $colList[] = 'DROP ' . $this->name($field);
} }
break; break;
case 'change': case 'change':
foreach ($column as $field => $col) { foreach ($column as $field => $col) {
if (!isset($col['name'])) { if (!isset($col['name'])) {
@ -535,7 +534,7 @@ class Mysql extends DboSource {
} }
$colList[] = 'CHANGE ' . $this->name($field) . ' ' . $this->buildColumn($col); $colList[] = 'CHANGE ' . $this->name($field) . ' ' . $this->buildColumn($col);
} }
break; break;
} }
} }
$colList = array_merge($colList, $this->_alterIndexes($curTable, $indexes)); $colList = array_merge($colList, $this->_alterIndexes($curTable, $indexes));
@ -684,24 +683,23 @@ class Mysql extends DboSource {
if (!$result) { if (!$result) {
$result->closeCursor(); $result->closeCursor();
return array(); return array();
} else { }
$tables = array(); $tables = array();
foreach ($result as $row) { foreach ($result as $row) {
$tables[$row['Name']] = (array)$row; $tables[$row['Name']] = (array)$row;
unset($tables[$row['Name']]['queryString']); unset($tables[$row['Name']]['queryString']);
if (!empty($row['Collation'])) { if (!empty($row['Collation'])) {
$charset = $this->getCharsetName($row['Collation']); $charset = $this->getCharsetName($row['Collation']);
if ($charset) { if ($charset) {
$tables[$row['Name']]['charset'] = $charset; $tables[$row['Name']]['charset'] = $charset;
}
} }
} }
$result->closeCursor();
if (is_string($name) && isset($tables[$name])) {
return $tables[$name];
}
return $tables;
} }
$result->closeCursor();
if (is_string($name) && isset($tables[$name])) {
return $tables[$name];
}
return $tables;
} }
/** /**

View file

@ -305,9 +305,8 @@ class Postgres extends DboSource {
} }
if (isset($this->_sequenceMap[$table][$field])) { if (isset($this->_sequenceMap[$table][$field])) {
return $this->_sequenceMap[$table][$field]; return $this->_sequenceMap[$table][$field];
} else {
return "{$table}_{$field}_seq";
} }
return "{$table}_{$field}_seq";
} }
/** /**
@ -521,13 +520,13 @@ class Postgres extends DboSource {
$col['name'] = $field; $col['name'] = $field;
$colList[] = 'ADD COLUMN ' . $this->buildColumn($col); $colList[] = 'ADD COLUMN ' . $this->buildColumn($col);
} }
break; break;
case 'drop': case 'drop':
foreach ($column as $field => $col) { foreach ($column as $field => $col) {
$col['name'] = $field; $col['name'] = $field;
$colList[] = 'DROP COLUMN ' . $this->name($field); $colList[] = 'DROP COLUMN ' . $this->name($field);
} }
break; break;
case 'change': case 'change':
foreach ($column as $field => $col) { foreach ($column as $field => $col) {
if (!isset($col['name'])) { if (!isset($col['name'])) {
@ -557,7 +556,7 @@ class Postgres extends DboSource {
} }
} }
break; break;
} }
} }
if (isset($indexes['drop']['PRIMARY'])) { if (isset($indexes['drop']['PRIMARY'])) {
@ -753,21 +752,19 @@ 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] = is_null($row[$index]) ? 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] = is_null($row[$index]) ? null : stream_get_contents($row[$index]);
break; break;
default: default:
$resultRow[$table][$column] = $row[$index]; $resultRow[$table][$column] = $row[$index];
break;
} }
} }
return $resultRow; return $resultRow;
} else {
$this->_result->closeCursor();
return false;
} }
$this->_result->closeCursor();
return false;
} }
/** /**
@ -793,7 +790,6 @@ class Postgres extends DboSource {
break; break;
default: default:
$result = (bool)$data; $result = (bool)$data;
break;
} }
if ($quote) { if ($quote) {

View file

@ -362,10 +362,9 @@ class Sqlite extends DboSource {
} }
} }
return $resultRow; return $resultRow;
} else {
$this->_result->closeCursor();
return false;
} }
$this->_result->closeCursor();
return false;
} }
/** /**

View file

@ -172,17 +172,16 @@ class Sqlserver extends DboSource {
if (!$result) { if (!$result) {
$result->closeCursor(); $result->closeCursor();
return array(); return array();
} else {
$tables = array();
while ($line = $result->fetch(PDO::FETCH_NUM)) {
$tables[] = $line[0];
}
$result->closeCursor();
parent::listSources($tables);
return $tables;
} }
$tables = array();
while ($line = $result->fetch(PDO::FETCH_NUM)) {
$tables[] = $line[0];
}
$result->closeCursor();
parent::listSources($tables);
return $tables;
} }
/** /**
@ -318,9 +317,8 @@ class Sqlserver extends DboSource {
$result[] = $prepend . $fields[$i]; $result[] = $prepend . $fields[$i];
} }
return $result; return $result;
} else {
return $fields;
} }
return $fields;
} }
/** /**
@ -539,10 +537,8 @@ class Sqlserver extends DboSource {
"; ";
} elseif (strpos($limit, 'FETCH') !== false) { } elseif (strpos($limit, 'FETCH') !== false) {
return "SELECT {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order} {$limit}"; return "SELECT {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order} {$limit}";
} else {
return "SELECT {$limit} {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order}";
} }
break; return "SELECT {$limit} {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order}";
case "schema": case "schema":
extract($data); extract($data);

View file

@ -592,25 +592,23 @@ class DboSource extends DataSource {
$recursive = $params[5 + $off]; $recursive = $params[5 + $off];
} }
return $args[2]->find('all', compact('conditions', 'fields', 'order', 'limit', 'page', 'recursive')); return $args[2]->find('all', compact('conditions', 'fields', 'order', 'limit', 'page', 'recursive'));
}
if (isset($params[3 + $off])) {
$recursive = $params[3 + $off];
}
return $args[2]->find('first', compact('conditions', 'fields', 'order', 'recursive'));
}
if (isset($args[1]) && $args[1] === true) {
return $this->fetchAll($args[0], true);
} elseif (isset($args[1]) && !is_array($args[1])) {
return $this->fetchAll($args[0], false);
} elseif (isset($args[1]) && is_array($args[1])) {
if (isset($args[2])) {
$cache = $args[2];
} else { } else {
if (isset($params[3 + $off])) { $cache = true;
$recursive = $params[3 + $off];
}
return $args[2]->find('first', compact('conditions', 'fields', 'order', 'recursive'));
}
} else {
if (isset($args[1]) && $args[1] === true) {
return $this->fetchAll($args[0], true);
} elseif (isset($args[1]) && !is_array($args[1])) {
return $this->fetchAll($args[0], false);
} elseif (isset($args[1]) && is_array($args[1])) {
if (isset($args[2])) {
$cache = $args[2];
} else {
$cache = true;
}
return $this->fetchAll($args[0], $args[1], array('cache' => $cache));
} }
return $this->fetchAll($args[0], $args[1], array('cache' => $cache));
} }
} }
@ -632,9 +630,8 @@ class DboSource extends DataSource {
$this->fetchVirtualField($resultRow); $this->fetchVirtualField($resultRow);
} }
return $resultRow; return $resultRow;
} else {
return null;
} }
return null;
} }
/** /**
@ -1569,7 +1566,7 @@ class DboSource extends DataSource {
} }
return true; return true;
} }
break; break;
case 'hasMany': case 'hasMany':
$assocData['fields'] = $this->fields($linkModel, $association, $assocData['fields']); $assocData['fields'] = $this->fields($linkModel, $association, $assocData['fields']);
if (!empty($assocData['foreignKey'])) { if (!empty($assocData['foreignKey'])) {
@ -1585,7 +1582,7 @@ class DboSource extends DataSource {
'offset' => $assocData['offset'], 'offset' => $assocData['offset'],
'group' => null 'group' => null
); );
break; break;
case 'hasAndBelongsToMany': case 'hasAndBelongsToMany':
$joinFields = array(); $joinFields = array();
$joinAssoc = null; $joinAssoc = null;
@ -1622,7 +1619,7 @@ class DboSource extends DataSource {
'conditions' => $this->getConstraint('hasAndBelongsToMany', $model, $linkModel, $joinAlias, $assocData, $association) 'conditions' => $this->getConstraint('hasAndBelongsToMany', $model, $linkModel, $joinAlias, $assocData, $association)
)) ))
); );
break; break;
} }
if (isset($query)) { if (isset($query)) {
return $this->buildStatement($query, $model); return $this->buildStatement($query, $model);
@ -2596,22 +2593,22 @@ class DboSource extends DataSource {
switch ($operator) { switch ($operator) {
case '=': case '=':
$operator = 'IN'; $operator = 'IN';
break; break;
case '!=': case '!=':
case '<>': case '<>':
$operator = 'NOT IN'; $operator = 'NOT IN';
break; break;
} }
$value = "({$value})"; $value = "({$value})";
} elseif ($null || $value === 'NULL') { } elseif ($null || $value === 'NULL') {
switch ($operator) { switch ($operator) {
case '=': case '=':
$operator = 'IS'; $operator = 'IS';
break; break;
case '!=': case '!=':
case '<>': case '<>':
$operator = 'IS NOT'; $operator = 'IS NOT';
break; break;
} }
} }
if ($virtual) { if ($virtual) {

View file

@ -1058,34 +1058,34 @@ class Model extends Object implements CakeEventListener {
switch ($key) { switch ($key) {
case 'fields': case 'fields':
$data = ''; $data = '';
break; break;
case 'foreignKey': case 'foreignKey':
$data = (($type === 'belongsTo') ? Inflector::underscore($assocKey) : Inflector::singularize($this->table)) . '_id'; $data = (($type === 'belongsTo') ? Inflector::underscore($assocKey) : Inflector::singularize($this->table)) . '_id';
break; break;
case 'associationForeignKey': case 'associationForeignKey':
$data = Inflector::singularize($this->{$class}->table) . '_id'; $data = Inflector::singularize($this->{$class}->table) . '_id';
break; break;
case 'with': case 'with':
$data = Inflector::camelize(Inflector::singularize($this->{$type}[$assocKey]['joinTable'])); $data = Inflector::camelize(Inflector::singularize($this->{$type}[$assocKey]['joinTable']));
$dynamicWith = true; $dynamicWith = true;
break; break;
case 'joinTable': case 'joinTable':
$tables = array($this->table, $this->{$class}->table); $tables = array($this->table, $this->{$class}->table);
sort($tables); sort($tables);
$data = $tables[0] . '_' . $tables[1]; $data = $tables[0] . '_' . $tables[1];
break; break;
case 'className': case 'className':
$data = $class; $data = $class;
break; break;
case 'unique': case 'unique':
$data = true; $data = true;
break; break;
} }
$this->{$type}[$assocKey][$key] = $data; $this->{$type}[$assocKey][$key] = $data;
} }
@ -1255,11 +1255,11 @@ class Model extends Object implements CakeEventListener {
isset($data['meridian']) && isset($data['meridian']) &&
!empty($data['hour']) && !empty($data['hour']) &&
$data['hour'] != 12 && $data['hour'] != 12 &&
'pm' == $data['meridian'] $data['meridian'] === 'pm'
) { ) {
$data['hour'] = $data['hour'] + 12; $data['hour'] = $data['hour'] + 12;
} }
if (isset($data['hour']) && isset($data['meridian']) && $data['hour'] == 12 && 'am' == $data['meridian']) { if (isset($data['hour']) && isset($data['meridian']) && $data['hour'] == 12 && $data['meridian'] === 'am') {
$data['hour'] = '00'; $data['hour'] = '00';
} }
if ($type === 'time') { if ($type === 'time') {
@ -2303,7 +2303,7 @@ class Model extends Object implements CakeEventListener {
$validationErrors[$association] = $this->{$association}->validationErrors; $validationErrors[$association] = $this->{$association}->validationErrors;
} }
$return[$association] = $validates; $return[$association] = $validates;
break; break;
case 'hasMany': case 'hasMany':
foreach ($values as $i => $value) { foreach ($values as $i => $value) {
if (isset($values[$i][$association])) { if (isset($values[$i][$association])) {
@ -2319,7 +2319,7 @@ class Model extends Object implements CakeEventListener {
$validates = false; $validates = false;
} }
$return[$association] = $_return; $return[$association] = $_return;
break; break;
} }
} }
} }

View file

@ -123,33 +123,32 @@ class Permission extends AppModel {
if (empty($perms)) { if (empty($perms)) {
continue; continue;
} else { }
$perms = Hash::extract($perms, '{n}.' . $this->alias); $perms = Hash::extract($perms, '{n}.' . $this->alias);
foreach ($perms as $perm) { foreach ($perms as $perm) {
if ($action === '*') { if ($action === '*') {
foreach ($permKeys as $key) { foreach ($permKeys as $key) {
if (!empty($perm)) { if (!empty($perm)) {
if ($perm[$key] == -1) { if ($perm[$key] == -1) {
return false; return false;
} elseif ($perm[$key] == 1) { } elseif ($perm[$key] == 1) {
$inherited[$key] = 1; $inherited[$key] = 1;
}
} }
} }
}
if (count($inherited) === count($permKeys)) { if (count($inherited) === count($permKeys)) {
return true;
}
} else {
switch ($perm['_' . $action]) {
case -1:
return false;
case 0:
continue;
case 1:
return true; return true;
}
} else {
switch ($perm['_' . $action]) {
case -1:
return false;
case 0:
continue;
case 1:
return true;
}
} }
} }
} }

View file

@ -148,9 +148,8 @@ class CakeValidationRule {
if (in_array($this->required, array('create', 'update'), true)) { if (in_array($this->required, array('create', 'update'), true)) {
if ($this->required === 'create' && !$this->isUpdate() || $this->required === 'update' && $this->isUpdate()) { if ($this->required === 'create' && !$this->isUpdate() || $this->required === 'update' && $this->isUpdate()) {
return true; return true;
} else {
return false;
} }
return false;
} }
return $this->required; return $this->required;

View file

@ -257,7 +257,15 @@ class CakeRequest implements ArrayAccess {
list($uri) = explode('?', $uri, 2); list($uri) = explode('?', $uri, 2);
} }
if (empty($uri) || $uri === '/' || $uri === '//' || $uri === '/index.php') { if (empty($uri) || $uri === '/' || $uri === '//' || $uri === '/index.php') {
return '/'; $uri = '/';
}
$endsWithIndex = '/webroot/index.php';
$endsWithLength = strlen($endsWithIndex);
if (
strlen($uri) >= $endsWithLength &&
substr($uri, -$endsWithLength) === $endsWithIndex
) {
$uri = '/';
} }
return $uri; return $uri;
} }
@ -265,7 +273,12 @@ class CakeRequest implements ArrayAccess {
/** /**
* Returns a base URL and sets the proper webroot * Returns a base URL and sets the proper webroot
* *
* If CakePHP is called with index.php in the URL even though
* URL Rewriting is activated (and thus not needed) it swallows
* the unnecessary part from $base to prevent issue #3318.
*
* @return string Base URL * @return string Base URL
* @link https://cakephp.lighthouseapp.com/projects/42648-cakephp/tickets/3318
*/ */
protected function _base() { protected function _base() {
$dir = $webroot = null; $dir = $webroot = null;
@ -283,6 +296,10 @@ class CakeRequest implements ArrayAccess {
if (!$baseUrl) { if (!$baseUrl) {
$base = dirname(env('PHP_SELF')); $base = dirname(env('PHP_SELF'));
$indexPos = strpos($base, '/webroot/index.php');
if ($indexPos !== false) {
$base = substr($base, 0, $indexPos) . '/webroot';
}
if ($webroot === 'webroot' && $webroot === basename($base)) { if ($webroot === 'webroot' && $webroot === basename($base)) {
$base = dirname($base); $base = dirname($base);
} }
@ -295,6 +312,7 @@ class CakeRequest implements ArrayAccess {
} }
$base = implode('/', array_map('rawurlencode', explode('/', $base))); $base = implode('/', array_map('rawurlencode', explode('/', $base)));
$this->webroot = $base . '/'; $this->webroot = $base . '/';
return $this->base = $base; return $this->base = $base;
} }

View file

@ -382,11 +382,10 @@ class CakeSocket {
if ($enableCryptoResult === true) { if ($enableCryptoResult === true) {
$this->encrypted = $enable; $this->encrypted = $enable;
return true; return true;
} else {
$errorMessage = __d('cake_dev', 'Unable to perform enableCrypto operation on CakeSocket');
$this->setLastError(null, $errorMessage);
throw new SocketException($errorMessage);
} }
$errorMessage = __d('cake_dev', 'Unable to perform enableCrypto operation on CakeSocket');
$this->setLastError(null, $errorMessage);
throw new SocketException($errorMessage);
} }
} }

View file

@ -1092,8 +1092,6 @@ class CakeEmail {
$content = implode("\n", $content) . "\n"; $content = implode("\n", $content) . "\n";
} }
$this->_textMessage = $this->_htmlMessage = '';
$this->_createBoundary();
$this->_message = $this->_render($this->_wrap($content)); $this->_message = $this->_render($this->_wrap($content));
$contents = $this->transportClass()->send($this); $contents = $this->transportClass()->send($this);
@ -1477,9 +1475,12 @@ class CakeEmail {
* @return array Email body ready to be sent * @return array Email body ready to be sent
*/ */
protected function _render($content) { protected function _render($content) {
$this->_textMessage = $this->_htmlMessage = '';
$content = implode("\n", $content); $content = implode("\n", $content);
$rendered = $this->_renderTemplates($content); $rendered = $this->_renderTemplates($content);
$this->_createBoundary();
$msg = array(); $msg = array();
$contentIds = array_filter((array)Hash::extract($this->_attachments, '{s}.contentId')); $contentIds = array_filter((array)Hash::extract($this->_attachments, '{s}.contentId'));
@ -1649,9 +1650,8 @@ class CakeEmail {
$charset = strtoupper($this->charset); $charset = strtoupper($this->charset);
if (array_key_exists($charset, $this->_contentTypeCharset)) { if (array_key_exists($charset, $this->_contentTypeCharset)) {
return strtoupper($this->_contentTypeCharset[$charset]); return strtoupper($this->_contentTypeCharset[$charset]);
} else {
return strtoupper($this->charset);
} }
return strtoupper($this->charset);
} }
} }

View file

@ -87,9 +87,8 @@ class AclPerson extends CakeTestModel {
} }
if (!$motherId) { if (!$motherId) {
return null; return null;
} else {
return array('AclPerson' => array('id' => $motherId));
} }
return array('AclPerson' => array('id' => $motherId));
} }
} }

View file

@ -3672,11 +3672,10 @@ class ContainableBehaviorTest extends CakeTestCase {
if (!is_array($Model)) { if (!is_array($Model)) {
$result = $Model->containments($contain); $result = $Model->containments($contain);
return $this->_containments($result['models']); return $this->_containments($result['models']);
} else { }
$result = $Model; $result = $Model;
foreach ($result as $i => $containment) { foreach ($result as $i => $containment) {
$result[$i] = array_diff_key($containment, array('instance' => true)); $result[$i] = array_diff_key($containment, array('instance' => true));
}
} }
return $result; return $result;
} }

View file

@ -142,15 +142,15 @@ class TestBehavior extends ModelBehavior {
switch ($settings['afterSave']) { switch ($settings['afterSave']) {
case 'on': case 'on':
$model->data[$model->alias]['aftersave'] = $string; $model->data[$model->alias]['aftersave'] = $string;
break; break;
case 'test': case 'test':
unset($model->data[$model->alias]['name']); unset($model->data[$model->alias]['name']);
break; break;
case 'test2': case 'test2':
return false; return false;
case 'modify': case 'modify':
$model->data[$model->alias]['name'] .= ' ' . $string; $model->data[$model->alias]['name'] .= ' ' . $string;
break; break;
} }
} }
@ -241,7 +241,7 @@ class TestBehavior extends ModelBehavior {
switch ($settings['afterDelete']) { switch ($settings['afterDelete']) {
case 'on': case 'on':
echo 'afterDelete success'; echo 'afterDelete success';
break; break;
} }
} }

View file

@ -29,6 +29,12 @@ App::uses('CakeRequest', 'Network');
*/ */
class TestCakeRequest extends CakeRequest { class TestCakeRequest extends CakeRequest {
/**
* reConstruct method
*
* @param string $url
* @param bool $parseEnvironment
*/
public function reConstruct($url = 'some/path', $parseEnvironment = true) { public function reConstruct($url = 'some/path', $parseEnvironment = true) {
$this->_base(); $this->_base();
if (empty($url)) { if (empty($url)) {
@ -49,10 +55,13 @@ class TestCakeRequest extends CakeRequest {
} }
/**
* Class CakeRequestTest
*/
class CakeRequestTest extends CakeTestCase { class CakeRequestTest extends CakeTestCase {
/** /**
* setup callback * Setup callback
* *
* @return void * @return void
*/ */
@ -69,7 +78,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* tearDown * TearDown
* *
* @return void * @return void
*/ */
@ -82,7 +91,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test that the autoparse = false constructor works. * Test that the autoparse = false constructor works.
* *
* @return void * @return void
*/ */
@ -95,7 +104,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test construction * Test construction
* *
* @return void * @return void
*/ */
@ -153,7 +162,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test addParams() method * Test addParams() method
* *
* @return void * @return void
*/ */
@ -170,7 +179,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test splicing in paths. * Test splicing in paths.
* *
* @return void * @return void
*/ */
@ -190,7 +199,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test parsing POST data into the object. * Test parsing POST data into the object.
* *
* @return void * @return void
*/ */
@ -241,7 +250,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test parsing PUT data into the object. * Test parsing PUT data into the object.
* *
* @return void * @return void
*/ */
@ -315,7 +324,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test parsing json PUT data into the object. * Test parsing json PUT data into the object.
* *
* @return void * @return void
*/ */
@ -332,7 +341,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test parsing of FILES array * Test parsing of FILES array
* *
* @return void * @return void
*/ */
@ -621,7 +630,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test method overrides coming in from POST data. * Test method overrides coming in from POST data.
* *
* @return void * @return void
*/ */
@ -640,7 +649,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test the clientIp method. * Test the clientIp method.
* *
* @return void * @return void
*/ */
@ -663,7 +672,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test the referer function. * Test the referrer function.
* *
* @return void * @return void
*/ */
@ -782,7 +791,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test the method() method. * Test the method() method.
* *
* @return void * @return void
*/ */
@ -794,7 +803,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test host retrieval. * Test host retrieval.
* *
* @return void * @return void
*/ */
@ -806,7 +815,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test domain retrieval. * Test domain retrieval.
* *
* @return void * @return void
*/ */
@ -821,7 +830,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test getting subdomains for a host. * Test getting subdomains for a host.
* *
* @return void * @return void
*/ */
@ -842,7 +851,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test ajax, flash and friends * Test ajax, flash and friends
* *
* @return void * @return void
*/ */
@ -876,7 +885,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test __call expcetions * Test __call exceptions
* *
* @expectedException CakeException * @expectedException CakeException
* @return void * @return void
@ -887,7 +896,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test is(ssl) * Test is(ssl)
* *
* @return void * @return void
*/ */
@ -920,7 +929,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test getting request params with object properties. * Test getting request params with object properties.
* *
* @return void * @return void
*/ */
@ -955,7 +964,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test the array access implementation * Test the array access implementation
* *
* @return void * @return void
*/ */
@ -986,7 +995,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test adding detectors and having them work. * Test adding detectors and having them work.
* *
* @return void * @return void
*/ */
@ -1043,16 +1052,17 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* helper function for testing callbacks. * Helper function for testing callbacks.
* *
* @return void * @param $request
* @return bool
*/ */
public function detectCallback($request) { public function detectCallback($request) {
return (bool)$request->return; return (bool)$request->return;
} }
/** /**
* test getting headers * Test getting headers
* *
* @return void * @return void
*/ */
@ -1066,7 +1076,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test accepts() with and without parameters * Test accepts() with and without parameters
* *
* @return void * @return void
*/ */
@ -1151,7 +1161,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* testBaseUrlAndWebrootWithModRewrite method * Test baseUrl and webroot with ModRewrite
* *
* @return void * @return void
*/ */
@ -1220,7 +1230,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* testBaseUrlwithModRewriteAlias method * Test baseUrl with ModRewrite alias
* *
* @return void * @return void
*/ */
@ -1248,7 +1258,71 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test base, webroot, and url parsing when there is no url rewriting * Test base, webroot, url and here parsing when there is url rewriting but
* CakePHP gets called with index.php in url nonetheless.
*
* Tests uri with
* - index.php/
* - index.php/
* - index.php/apples/
* - index.php/bananas/eat/tasty_banana
*
* @link https://cakephp.lighthouseapp.com/projects/42648-cakephp/tickets/3318
*/
public function testBaseUrlWithModRewriteAndIndexPhp() {
$_SERVER['REQUEST_URI'] = '/cakephp/app/webroot/index.php';
$_SERVER['PHP_SELF'] = '/cakephp/app/webroot/index.php';
unset($_SERVER['PATH_INFO']);
$request = new CakeRequest();
$this->assertEquals('/cakephp', $request->base);
$this->assertEquals('/cakephp/', $request->webroot);
$this->assertEquals('', $request->url);
$this->assertEquals('/cakephp/', $request->here);
$_SERVER['REQUEST_URI'] = '/cakephp/app/webroot/index.php/';
$_SERVER['PHP_SELF'] = '/cakephp/app/webroot/index.php/';
$_SERVER['PATH_INFO'] = '/';
$request = new CakeRequest();
$this->assertEquals('/cakephp', $request->base);
$this->assertEquals('/cakephp/', $request->webroot);
$this->assertEquals('', $request->url);
$this->assertEquals('/cakephp/', $request->here);
$_SERVER['REQUEST_URI'] = '/cakephp/app/webroot/index.php/apples';
$_SERVER['PHP_SELF'] = '/cakephp/app/webroot/index.php/apples';
$_SERVER['PATH_INFO'] = '/apples';
$request = new CakeRequest();
$this->assertEquals('/cakephp', $request->base);
$this->assertEquals('/cakephp/', $request->webroot);
$this->assertEquals('apples', $request->url);
$this->assertEquals('/cakephp/apples', $request->here);
$_SERVER['REQUEST_URI'] = '/cakephp/app/webroot/index.php/melons/share/';
$_SERVER['PHP_SELF'] = '/cakephp/app/webroot/index.php/melons/share/';
$_SERVER['PATH_INFO'] = '/melons/share/';
$request = new CakeRequest();
$this->assertEquals('/cakephp', $request->base);
$this->assertEquals('/cakephp/', $request->webroot);
$this->assertEquals('melons/share/', $request->url);
$this->assertEquals('/cakephp/melons/share/', $request->here);
$_SERVER['REQUEST_URI'] = '/cakephp/app/webroot/index.php/bananas/eat/tasty_banana';
$_SERVER['PHP_SELF'] = '/cakephp/app/webroot/index.php/bananas/eat/tasty_banana';
$_SERVER['PATH_INFO'] = '/bananas/eat/tasty_banana';
$request = new CakeRequest();
$this->assertEquals('/cakephp', $request->base);
$this->assertEquals('/cakephp/', $request->webroot);
$this->assertEquals('bananas/eat/tasty_banana', $request->url);
$this->assertEquals('/cakephp/bananas/eat/tasty_banana', $request->here);
}
/**
* Test base, webroot, and url parsing when there is no url rewriting
* *
* @return void * @return void
*/ */
@ -1272,7 +1346,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* testBaseUrlAndWebrootWithBaseUrl method * Test baseUrl and webroot with baseUrl
* *
* @return void * @return void
*/ */
@ -1321,7 +1395,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test baseUrl with no rewrite and using the top level index.php. * Test baseUrl with no rewrite and using the top level index.php.
* *
* @return void * @return void
*/ */
@ -1359,7 +1433,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test baseUrl with no rewrite, and using the app/webroot/index.php file as is normal with virtual hosts. * Test baseUrl with no rewrite, and using the app/webroot/index.php file as is normal with virtual hosts.
* *
* @return void * @return void
*/ */
@ -1405,9 +1479,9 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* generator for environment configurations * Generator for environment configurations
* *
* @return void * @return array Environment array
*/ */
public static function environmentGenerator() { public static function environmentGenerator() {
return array( return array(
@ -1779,9 +1853,12 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* testEnvironmentDetection method * Test environment detection
* *
* @dataProvider environmentGenerator * @dataProvider environmentGenerator
* @param $name
* @param $env
* @param $expected
* @return void * @return void
*/ */
public function testEnvironmentDetection($name, $env, $expected) { public function testEnvironmentDetection($name, $env, $expected) {
@ -1798,7 +1875,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test the query() method * Test the query() method
* *
* @return void * @return void
*/ */
@ -1816,7 +1893,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test the query() method with arrays passed via $_GET * Test the query() method with arrays passed via $_GET
* *
* @return void * @return void
*/ */
@ -1857,7 +1934,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test the data() method reading * Test the data() method reading
* *
* @return void * @return void
*/ */
@ -1876,7 +1953,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test writing with data() * Test writing with data()
* *
* @return void * @return void
*/ */
@ -1898,7 +1975,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test writing falsey values. * Test writing falsey values.
* *
* @return void * @return void
*/ */
@ -1919,7 +1996,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test accept language * Test accept language
* *
* @return void * @return void
*/ */
@ -1962,7 +2039,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test the here() method * Test the here() method
* *
* @return void * @return void
*/ */
@ -2065,7 +2142,7 @@ XML;
} }
/** /**
* TestOnlyAllow * Test onlyAllow method
* *
* @return void * @return void
*/ */
@ -2080,7 +2157,7 @@ XML;
} }
/** /**
* TestOnlyAllow throwing exception * Test onlyAllow throwing exception
* *
*/ */
public function testOnlyAllowException() { public function testOnlyAllowException() {

View file

@ -65,6 +65,14 @@ class TestCakeEmail extends CakeEmail {
return $this->_encode($text); return $this->_encode($text);
} }
/**
* Render to protected method
*
*/
public function render($content) {
return $this->_render($content);
}
} }
/* /*
@ -1578,6 +1586,22 @@ class CakeEmailTest extends CakeTestCase {
$this->assertSame($expected, $result); $this->assertSame($expected, $result);
} }
/**
* testRender method
*
* @return void
*/
public function testRenderWithLayoutAndAttachment() {
$this->CakeEmail->emailFormat('html');
$this->CakeEmail->template('html', 'default');
$this->CakeEmail->attachments(array(CAKE . 'basics.php'));
$result = $this->CakeEmail->render(array());
$this->assertNotEmpty($result);
$result = $this->CakeEmail->getBoundary();
$this->assertNotEmpty($result);
}
/** /**
* testConstructWithConfigArray method * testConstructWithConfigArray method
* *

View file

@ -122,9 +122,8 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command {
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT); exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
} elseif (!isset($result) || $result->errorCount() > 0) { } elseif (!isset($result) || $result->errorCount() > 0) {
exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT); exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
} else {
exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
} }
exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
} }
} }

View file

@ -47,10 +47,9 @@ class CakeTestModel extends Model {
case case
(is_string($queryData['fields']) && !($queryData['fields'] == $pk || $queryData['fields'] == $aliasedPk)) || (is_string($queryData['fields']) && !($queryData['fields'] == $pk || $queryData['fields'] == $aliasedPk)) ||
(is_array($queryData['fields']) && !(array_key_exists($pk, $queryData['fields']) || array_key_exists($aliasedPk, $queryData['fields']))): (is_array($queryData['fields']) && !(array_key_exists($pk, $queryData['fields']) || array_key_exists($aliasedPk, $queryData['fields']))):
break; break;
default: default:
$queryData['order'] = array($this->alias . '.' . $this->primaryKey => 'ASC'); $queryData['order'] = array($this->alias . '.' . $this->primaryKey => 'ASC');
break;
} }
return $queryData; return $queryData;
} }

View file

@ -97,14 +97,13 @@ class CakeTime {
* *
* @param string $name Variable name * @param string $name Variable name
* @param mixes $value Variable value * @param mixes $value Variable value
* @return void
*/ */
public function __set($name, $value) { public function __set($name, $value) {
switch ($name) { switch ($name) {
case 'niceFormat': case 'niceFormat':
self::${$name} = $value; self::${$name} = $value;
break; break;
default:
break;
} }
} }

View file

@ -230,24 +230,24 @@ class Debugger {
case E_USER_ERROR: case E_USER_ERROR:
$error = 'Fatal Error'; $error = 'Fatal Error';
$level = LOG_ERR; $level = LOG_ERR;
break; break;
case E_WARNING: case E_WARNING:
case E_USER_WARNING: case E_USER_WARNING:
case E_COMPILE_WARNING: case E_COMPILE_WARNING:
case E_RECOVERABLE_ERROR: case E_RECOVERABLE_ERROR:
$error = 'Warning'; $error = 'Warning';
$level = LOG_WARNING; $level = LOG_WARNING;
break; break;
case E_NOTICE: case E_NOTICE:
case E_USER_NOTICE: case E_USER_NOTICE:
$error = 'Notice'; $error = 'Notice';
$level = LOG_NOTICE; $level = LOG_NOTICE;
break; break;
case E_DEPRECATED: case E_DEPRECATED:
case E_USER_DEPRECATED: case E_USER_DEPRECATED:
$error = 'Deprecated'; $error = 'Deprecated';
$level = LOG_NOTICE; $level = LOG_NOTICE;
break; break;
default: default:
return; return;
} }

View file

@ -516,11 +516,10 @@ class Folder {
umask($old); umask($old);
$this->_messages[] = __d('cake_dev', '%s created', $pathname); $this->_messages[] = __d('cake_dev', '%s created', $pathname);
return true; return true;
} else {
umask($old);
$this->_errors[] = __d('cake_dev', '%s NOT created', $pathname);
return false;
} }
umask($old);
$this->_errors[] = __d('cake_dev', '%s NOT created', $pathname);
return false;
} }
} }
return false; return false;
@ -810,9 +809,8 @@ class Folder {
if (!empty($newparts)) { if (!empty($newparts)) {
array_pop($newparts); array_pop($newparts);
continue; continue;
} else {
return false;
} }
return false;
} }
$newparts[] = $part; $newparts[] = $part;
} }

View file

@ -54,7 +54,6 @@ class Hash {
} else { } else {
return null; return null;
} }
} }
return $data; return $data;
} }

View file

@ -308,7 +308,7 @@ class Inflector {
} else { } else {
self::$_transliteration = $rules + self::$_transliteration; self::$_transliteration = $rules + self::$_transliteration;
} }
break; break;
default: default:
foreach ($rules as $rule => $pattern) { foreach ($rules as $rule => $pattern) {
@ -334,7 +334,6 @@ class Inflector {
} }
} }
self::${$var}['rules'] = $rules + self::${$var}['rules']; self::${$var}['rules'] = $rules + self::${$var}['rules'];
break;
} }
} }

View file

@ -255,7 +255,6 @@ 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 Validation::comparison()');
break;
} }
return false; return false;
} }
@ -822,9 +821,8 @@ class Validation {
protected static function _check($check, $regex) { protected static function _check($check, $regex) {
if (is_string($regex) && preg_match($regex, $check)) { if (is_string($regex) && preg_match($regex, $check)) {
return true; return true;
} else {
return false;
} }
return false;
} }
/** /**

View file

@ -662,18 +662,16 @@ class Helper extends Object {
switch ($field) { switch ($field) {
case '_method': case '_method':
$name = $field; $name = $field;
break; break;
default: default:
$name = 'data[' . implode('][', $this->entity()) . ']'; $name = 'data[' . implode('][', $this->entity()) . ']';
break;
} }
if (is_array($options)) { if (is_array($options)) {
$options[$key] = $name; $options[$key] = $name;
return $options; return $options;
} else {
return $name;
} }
return $name;
} }
/** /**
@ -729,9 +727,8 @@ class Helper extends Object {
if (is_array($options)) { if (is_array($options)) {
$options[$key] = $result; $options[$key] = $result;
return $options; return $options;
} else {
return $result;
} }
return $result;
} }
/** /**
@ -920,7 +917,7 @@ class Helper extends Object {
do { do {
$oldstring = $this->_cleaned; $oldstring = $this->_cleaned;
$this->_cleaned = preg_replace('#</*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i', "", $this->_cleaned); $this->_cleaned = preg_replace('#</*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i', "", $this->_cleaned);
} while ($oldstring != $this->_cleaned); } while ($oldstring !== $this->_cleaned);
$this->_cleaned = str_replace(array("&amp;", "&lt;", "&gt;"), array("&amp;amp;", "&amp;lt;", "&amp;gt;"), $this->_cleaned); $this->_cleaned = str_replace(array("&amp;", "&lt;", "&gt;"), array("&amp;amp;", "&amp;lt;", "&amp;gt;"), $this->_cleaned);
} }

View file

@ -205,9 +205,8 @@ class FormHelper extends AppHelper {
return $this->fieldset[$model]['fields']; return $this->fieldset[$model]['fields'];
} elseif (isset($this->fieldset[$model]['fields'][$field])) { } elseif (isset($this->fieldset[$model]['fields'][$field])) {
return $this->fieldset[$model]['fields'][$field]; return $this->fieldset[$model]['fields'][$field];
} else {
return isset($object->hasAndBelongsToMany[$field]) ? array('type' => 'multiple') : null;
} }
return isset($object->hasAndBelongsToMany[$field]) ? array('type' => 'multiple') : null;
} }
if ($key === 'errors' && !isset($this->validationErrors[$model])) { if ($key === 'errors' && !isset($this->validationErrors[$model])) {
@ -232,10 +231,9 @@ class FormHelper extends AppHelper {
if ($key === 'validates') { if ($key === 'validates') {
if (empty($field)) { if (empty($field)) {
return $this->fieldset[$model]['validates']; return $this->fieldset[$model]['validates'];
} else {
return isset($this->fieldset[$model]['validates'][$field]) ?
$this->fieldset[$model]['validates'] : null;
} }
return isset($this->fieldset[$model]['validates'][$field]) ?
$this->fieldset[$model]['validates'] : null;
} }
} }
@ -407,7 +405,7 @@ class FormHelper extends AppHelper {
switch (strtolower($options['type'])) { switch (strtolower($options['type'])) {
case 'get': case 'get':
$htmlAttributes['method'] = 'get'; $htmlAttributes['method'] = 'get';
break; break;
case 'file': case 'file':
$htmlAttributes['enctype'] = 'multipart/form-data'; $htmlAttributes['enctype'] = 'multipart/form-data';
$options['type'] = ($created) ? 'put' : 'post'; $options['type'] = ($created) ? 'put' : 'post';
@ -420,7 +418,6 @@ class FormHelper extends AppHelper {
)); ));
default: default:
$htmlAttributes['method'] = 'post'; $htmlAttributes['method'] = 'post';
break;
} }
$this->requestType = strtolower($options['type']); $this->requestType = strtolower($options['type']);
@ -734,9 +731,8 @@ class FormHelper extends AppHelper {
$tag = is_string($options['wrap']) ? $options['wrap'] : 'div'; $tag = is_string($options['wrap']) ? $options['wrap'] : 'div';
unset($options['wrap']); unset($options['wrap']);
return $this->Html->tag($tag, $error, $options); return $this->Html->tag($tag, $error, $options);
} else {
return $error;
} }
return $error;
} }
/** /**
@ -2464,16 +2460,16 @@ class FormHelper extends AppHelper {
$selects[] = $this->year( $selects[] = $this->year(
$fieldName, $minYear, $maxYear, $attrs['Year'] $fieldName, $minYear, $maxYear, $attrs['Year']
); );
break; break;
case 'M': case 'M':
$attrs['Month']['value'] = $month; $attrs['Month']['value'] = $month;
$attrs['Month']['monthNames'] = $monthNames; $attrs['Month']['monthNames'] = $monthNames;
$selects[] = $this->month($fieldName, $attrs['Month']); $selects[] = $this->month($fieldName, $attrs['Month']);
break; break;
case 'D': case 'D':
$attrs['Day']['value'] = $day; $attrs['Day']['value'] = $day;
$selects[] = $this->day($fieldName, $attrs['Day']); $selects[] = $this->day($fieldName, $attrs['Day']);
break; break;
} }
} }
$opt = implode($separator, $selects); $opt = implode($separator, $selects);
@ -2485,7 +2481,7 @@ class FormHelper extends AppHelper {
$attrs['Minute']['value'] = $min; $attrs['Minute']['value'] = $min;
$opt .= $this->hour($fieldName, true, $attrs['Hour']) . ':' . $opt .= $this->hour($fieldName, true, $attrs['Hour']) . ':' .
$this->minute($fieldName, $attrs['Minute']); $this->minute($fieldName, $attrs['Minute']);
break; break;
case '12': case '12':
$attrs['Hour']['value'] = $hour; $attrs['Hour']['value'] = $hour;
$attrs['Minute']['value'] = $min; $attrs['Minute']['value'] = $min;
@ -2493,7 +2489,7 @@ class FormHelper extends AppHelper {
$opt .= $this->hour($fieldName, false, $attrs['Hour']) . ':' . $opt .= $this->hour($fieldName, false, $attrs['Hour']) . ':' .
$this->minute($fieldName, $attrs['Minute']) . ' ' . $this->minute($fieldName, $attrs['Minute']) . ' ' .
$this->meridian($fieldName, $attrs['Meridian']); $this->meridian($fieldName, $attrs['Meridian']);
break; break;
} }
return $opt; return $opt;
} }
@ -2581,9 +2577,8 @@ class FormHelper extends AppHelper {
if (is_array($options)) { if (is_array($options)) {
$options[$key] = $name; $options[$key] = $name;
return $options; return $options;
} else {
return $name;
} }
return $name;
} }
return parent::_name($options, $field, $key); return parent::_name($options, $field, $key);
} }
@ -2727,20 +2722,20 @@ class FormHelper extends AppHelper {
$data[sprintf('%02d', $i)] = sprintf('%02d', $i); $data[sprintf('%02d', $i)] = sprintf('%02d', $i);
$i += $interval; $i += $interval;
} }
break; break;
case 'hour': case 'hour':
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$data[sprintf('%02d', $i)] = $i; $data[sprintf('%02d', $i)] = $i;
} }
break; break;
case 'hour24': case 'hour24':
for ($i = 0; $i <= 23; $i++) { for ($i = 0; $i <= 23; $i++) {
$data[sprintf('%02d', $i)] = $i; $data[sprintf('%02d', $i)] = $i;
} }
break; break;
case 'meridian': case 'meridian':
$data = array('am' => 'am', 'pm' => 'pm'); $data = array('am' => 'am', 'pm' => 'pm');
break; break;
case 'day': case 'day':
$min = 1; $min = 1;
$max = 31; $max = 31;
@ -2755,7 +2750,7 @@ class FormHelper extends AppHelper {
for ($i = $min; $i <= $max; $i++) { for ($i = $min; $i <= $max; $i++) {
$data[sprintf('%02d', $i)] = $i; $data[sprintf('%02d', $i)] = $i;
} }
break; break;
case 'month': case 'month':
if ($options['monthNames'] === true) { if ($options['monthNames'] === true) {
$data['01'] = __d('cake', 'January'); $data['01'] = __d('cake', 'January');
@ -2777,7 +2772,7 @@ class FormHelper extends AppHelper {
$data[sprintf("%02s", $m)] = strftime("%m", mktime(1, 1, 1, $m, 1, 1999)); $data[sprintf("%02s", $m)] = strftime("%m", mktime(1, 1, 1, $m, 1, 1999));
} }
} }
break; break;
case 'year': case 'year':
$current = intval(date('Y')); $current = intval(date('Y'));
@ -2799,7 +2794,7 @@ class FormHelper extends AppHelper {
if ($options['order'] !== 'asc') { if ($options['order'] !== 'asc') {
$data = array_reverse($data, true); $data = array_reverse($data, true);
} }
break; break;
} }
$this->_options[$name] = $data; $this->_options[$name] = $data;
return $this->_options[$name]; return $this->_options[$name];

View file

@ -289,9 +289,8 @@ class HtmlHelper extends AppHelper {
if (empty($options['block'])) { if (empty($options['block'])) {
return $out; return $out;
} else {
$this->_View->append($options['block'], $out);
} }
$this->_View->append($options['block'], $out);
} }
/** /**
@ -473,9 +472,8 @@ class HtmlHelper extends AppHelper {
if (empty($options['block'])) { if (empty($options['block'])) {
return $out; return $out;
} else {
$this->_View->append($options['block'], $out);
} }
$this->_View->append($options['block'], $out);
} }
/** /**
@ -696,9 +694,8 @@ class HtmlHelper extends AppHelper {
} }
} }
return implode($separator, $out); return implode($separator, $out);
} else {
return null;
} }
return null;
} }
/** /**

View file

@ -235,7 +235,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
case 'slideDown': case 'slideDown':
case 'slideUp': case 'slideUp':
$effect = ".$name($speed);"; $effect = ".$name($speed);";
break; break;
} }
return $this->selection . $effect; return $this->selection . $effect;
} }

View file

@ -147,25 +147,24 @@ abstract class JsBaseEngineHelper extends AppHelper {
switch (true) { switch (true) {
case (is_array($val) || is_object($val)): case (is_array($val) || is_object($val)):
$val = $this->object($val); $val = $this->object($val);
break; break;
case ($val === null): case ($val === null):
$val = 'null'; $val = 'null';
break; break;
case (is_bool($val)): case (is_bool($val)):
$val = ($val === true) ? 'true' : 'false'; $val = ($val === true) ? 'true' : 'false';
break; break;
case (is_int($val)): case (is_int($val)):
$val = $val; $val = $val;
break; break;
case (is_float($val)): case (is_float($val)):
$val = sprintf("%.11f", $val); $val = sprintf("%.11f", $val);
break; break;
default: default:
$val = $this->escape($val); $val = $this->escape($val);
if ($quoteString) { if ($quoteString) {
$val = '"' . $val . '"'; $val = '"' . $val . '"';
} }
break;
} }
return $val; return $val;
} }

View file

@ -205,10 +205,10 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
switch ($name) { switch ($name) {
case 'hide': case 'hide':
$effect = 'setStyle("display", "none")'; $effect = 'setStyle("display", "none")';
break; break;
case 'show': case 'show':
$effect = 'setStyle("display", "")'; $effect = 'setStyle("display", "")';
break; break;
case 'fadeIn': case 'fadeIn':
case 'fadeOut': case 'fadeOut':
case 'slideIn': case 'slideIn':
@ -219,7 +219,7 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
$effect .= "set(\"$effectName\", {duration:$speed})."; $effect .= "set(\"$effectName\", {duration:$speed}).";
} }
$effect .= "$effectName(\"$direction\")"; $effect .= "$effectName(\"$direction\")";
break; break;
} }
return $this->selection . '.' . $effect . ';'; return $this->selection . '.' . $effect . ';';
} }

View file

@ -507,22 +507,21 @@ class PaginatorHelper extends AppHelper {
} }
$link = $this->link($title, $url, compact('escape', 'model') + $options); $link = $this->link($title, $url, compact('escape', 'model') + $options);
return $this->Html->tag($tag, $link, compact('class')); return $this->Html->tag($tag, $link, compact('class'));
} else {
unset($options['rel']);
if (!$tag) {
if ($disabledTag) {
$tag = $disabledTag;
$disabledTag = null;
} else {
$tag = $_defaults['tag'];
}
}
if ($disabledTag) {
$title = $this->Html->tag($disabledTag, $title, compact('escape') + $options);
return $this->Html->tag($tag, $title, compact('class'));
}
return $this->Html->tag($tag, $title, compact('escape', 'class') + $options);
} }
unset($options['rel']);
if (!$tag) {
if ($disabledTag) {
$tag = $disabledTag;
$disabledTag = null;
} else {
$tag = $_defaults['tag'];
}
}
if ($disabledTag) {
$title = $this->Html->tag($disabledTag, $title, compact('escape') + $options);
return $this->Html->tag($tag, $title, compact('class'));
}
return $this->Html->tag($tag, $title, compact('escape', 'class') + $options);
} }
/** /**
@ -644,10 +643,10 @@ class PaginatorHelper extends AppHelper {
} }
$out = $start . $options['separator'][0] . $end . $options['separator'][1]; $out = $start . $options['separator'][0] . $end . $options['separator'][1];
$out .= $paging['count']; $out .= $paging['count'];
break; break;
case 'pages': case 'pages':
$out = $paging['page'] . $options['separator'] . $paging['pageCount']; $out = $paging['page'] . $options['separator'] . $paging['pageCount'];
break; break;
default: default:
$map = array( $map = array(
'%page%' => $paging['page'], '%page%' => $paging['page'],
@ -664,7 +663,6 @@ class PaginatorHelper extends AppHelper {
'{:page}', '{:pages}', '{:current}', '{:count}', '{:start}', '{:end}', '{:model}' '{:page}', '{:pages}', '{:current}', '{:count}', '{:start}', '{:end}', '{:model}'
); );
$out = str_replace($newKeys, array_values($map), $out); $out = str_replace($newKeys, array_values($map), $out);
break;
} }
return $out; return $out;
} }

View file

@ -212,17 +212,17 @@ class PrototypeEngineHelper extends JsBaseEngineHelper {
case 'hide': case 'hide':
case 'show': case 'show':
$effect = $this->selection . '.' . $name . '();'; $effect = $this->selection . '.' . $name . '();';
break; break;
case 'slideIn': case 'slideIn':
case 'slideOut': case 'slideOut':
$name = ($name === 'slideIn') ? 'slideDown' : 'slideUp'; $name = ($name === 'slideIn') ? 'slideDown' : 'slideUp';
$effect = 'Effect.' . $name . '(' . $this->selection . $optionString . ');'; $effect = 'Effect.' . $name . '(' . $this->selection . $optionString . ');';
break; break;
case 'fadeIn': case 'fadeIn':
case 'fadeOut': case 'fadeOut':
$name = ($name === 'fadeIn') ? 'appear' : 'fade'; $name = ($name === 'fadeIn') ? 'appear' : 'fade';
$effect = $this->selection . '.' . $name . '(' . substr($optionString, 2) . ');'; $effect = $this->selection . '.' . $name . '(' . substr($optionString, 2) . ');';
break; break;
} }
return $effect; return $effect;
} }

View file

@ -208,7 +208,7 @@ class RssHelper extends AppHelper {
switch ($key) { switch ($key) {
case 'pubDate' : case 'pubDate' :
$val = $this->time($val); $val = $this->time($val);
break; break;
case 'category' : case 'category' :
if (is_array($val) && !empty($val[0])) { if (is_array($val) && !empty($val[0])) {
foreach ($val as $category) { foreach ($val as $category) {
@ -224,7 +224,7 @@ class RssHelper extends AppHelper {
} elseif (is_array($val) && isset($val['domain'])) { } elseif (is_array($val) && isset($val['domain'])) {
$attrib['domain'] = $val['domain']; $attrib['domain'] = $val['domain'];
} }
break; break;
case 'link': case 'link':
case 'guid': case 'guid':
case 'comments': case 'comments':
@ -234,7 +234,7 @@ class RssHelper extends AppHelper {
$val = $val['url']; $val = $val['url'];
} }
$val = $this->url($val, true); $val = $this->url($val, true);
break; break;
case 'source': case 'source':
if (is_array($val) && isset($val['url'])) { if (is_array($val) && isset($val['url'])) {
$attrib['url'] = $this->url($val['url'], true); $attrib['url'] = $this->url($val['url'], true);
@ -243,7 +243,7 @@ class RssHelper extends AppHelper {
$attrib['url'] = $this->url($val[0], true); $attrib['url'] = $this->url($val[0], true);
$val = $val[1]; $val = $val[1];
} }
break; break;
case 'enclosure': case 'enclosure':
if (is_string($val['url']) && is_file(WWW_ROOT . $val['url']) && file_exists(WWW_ROOT . $val['url'])) { if (is_string($val['url']) && is_file(WWW_ROOT . $val['url']) && file_exists(WWW_ROOT . $val['url'])) {
if (!isset($val['length']) && strpos($val['url'], '://') === false) { if (!isset($val['length']) && strpos($val['url'], '://') === false) {
@ -256,7 +256,7 @@ class RssHelper extends AppHelper {
$val['url'] = $this->url($val['url'], true); $val['url'] = $this->url($val['url'], true);
$attrib = $val; $attrib = $val;
$val = null; $val = null;
break; break;
default: default:
$attrib = $att; $attrib = $att;
} }

View file

@ -75,10 +75,9 @@ class TimeHelper extends AppHelper {
switch ($name) { switch ($name) {
case 'niceFormat': case 'niceFormat':
$this->_engine->{$name} = $value; $this->_engine->{$name} = $value;
break; break;
default: default:
$this->{$name} = $value; $this->{$name} = $value;
break;
} }
} }

View file

@ -564,9 +564,8 @@ class View extends Object {
//@codingStandardsIgnoreEnd //@codingStandardsIgnoreEnd
unset($out); unset($out);
return false; return false;
} else {
return substr($out, strlen($match[0]));
} }
return substr($out, strlen($match[0]));
} }
} }

View file

@ -404,13 +404,13 @@ if (!function_exists('cache')) {
switch (strtolower($target)) { switch (strtolower($target)) {
case 'cache': case 'cache':
$filename = CACHE . $path; $filename = CACHE . $path;
break; break;
case 'public': case 'public':
$filename = WWW_ROOT . $path; $filename = WWW_ROOT . $path;
break; break;
case 'tmp': case 'tmp':
$filename = TMP . $path; $filename = TMP . $path;
break; break;
} }
$timediff = $expires - $now; $timediff = $expires - $now;
$filetime = false; $filetime = false;
@ -472,29 +472,6 @@ if (!function_exists('clearCache')) {
return false; return false;
} }
foreach ($files as $file) {
if (is_file($file) && strrpos($file, DS . 'empty') !== strlen($file) - 6) {
//@codingStandardsIgnoreStart
@unlink($file);
//@codingStandardsIgnoreEnd
}
}
return true;
} else {
$cache = array(
CACHE . $type . DS . '*' . $params . $ext,
CACHE . $type . DS . '*' . $params . '_*' . $ext
);
$files = array();
while ($search = array_shift($cache)) {
$results = glob($search);
if ($results !== false) {
$files = array_merge($files, $results);
}
}
if (empty($files)) {
return false;
}
foreach ($files as $file) { foreach ($files as $file) {
if (is_file($file) && strrpos($file, DS . 'empty') !== strlen($file) - 6) { if (is_file($file) && strrpos($file, DS . 'empty') !== strlen($file) - 6) {
//@codingStandardsIgnoreStart //@codingStandardsIgnoreStart
@ -504,6 +481,29 @@ if (!function_exists('clearCache')) {
} }
return true; return true;
} }
$cache = array(
CACHE . $type . DS . '*' . $params . $ext,
CACHE . $type . DS . '*' . $params . '_*' . $ext
);
$files = array();
while ($search = array_shift($cache)) {
$results = glob($search);
if ($results !== false) {
$files = array_merge($files, $results);
}
}
if (empty($files)) {
return false;
}
foreach ($files as $file) {
if (is_file($file) && strrpos($file, DS . 'empty') !== strlen($file) - 6) {
//@codingStandardsIgnoreStart
@unlink($file);
//@codingStandardsIgnoreEnd
}
}
return true;
} elseif (is_array($params)) { } elseif (is_array($params)) {
foreach ($params as $file) { foreach ($params as $file) {
clearCache($file, $type, $ext); clearCache($file, $type, $ext);