Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.3' into 3.0
Browse files Browse the repository at this point in the history
Conflicts:
	lib/Cake/Console/ConsoleErrorHandler.php
	lib/Cake/Console/Shell.php
	lib/Cake/Console/Templates/skel/View/Pages/home.ctp
	lib/Cake/Controller/Component/Acl/IniAcl.php
	lib/Cake/Controller/Component/EmailComponent.php
	lib/Cake/Controller/Component/SecurityComponent.php
	lib/Cake/Controller/Controller.php
	lib/Cake/Core/App.php
	lib/Cake/Core/Configure.php
	lib/Cake/Error/ExceptionRenderer.php
	lib/Cake/I18n/I18n.php
	lib/Cake/I18n/Multibyte.php
	lib/Cake/Model/Datasource/Session.php
	lib/Cake/Network/Request.php
	lib/Cake/Routing/Router.php
	lib/Cake/Test/Case/Core/AppTest.php
	lib/Cake/Test/Case/Log/CakeLogTest.php
	lib/Cake/Test/Case/Routing/RouterTest.php
	lib/Cake/Test/TestApp/View/Layouts/flash.ctp
	lib/Cake/Test/TestCase/Cache/Engine/MemcacheEngineTest.php
	lib/Cake/Test/TestCase/Console/Command/Task/ExtractTaskTest.php
	lib/Cake/Test/TestCase/Controller/Component/PaginatorComponentTest.php
	lib/Cake/Test/TestCase/Utility/TimeTest.php
	lib/Cake/Test/TestCase/View/Helper/FormHelperTest.php
	lib/Cake/TestSuite/TestSuiteCommand.php
	lib/Cake/Utility/Number.php
	lib/Cake/Utility/Time.php
	lib/Cake/Utility/Validation.php
	lib/Cake/View/View.php
	lib/Cake/basics.php
	lib/Cake/bootstrap.php
  • Loading branch information
markstory committed Oct 28, 2012
2 parents 4ded3b8 + c794e29 commit 8b6cd24
Show file tree
Hide file tree
Showing 100 changed files with 870 additions and 515 deletions.
27 changes: 13 additions & 14 deletions App/Console/cake
Expand Up @@ -17,22 +17,21 @@
# @license MIT License (http://www.opensource.org/licenses/mit-license.php)
#
################################################################################
if [[ `uname` =~ 'Darwin' ]]; then
ME=$0
else
ME=$(readlink -f $0)
fi
LIB=$(cd -P -- "$(dirname -- "$ME")" && pwd -P) && LIB=$LIB/$(basename -- "$ME")

while [ -h "$LIB" ]; do
DIR=$(dirname -- "$LIB")
SYM=$(readlink "$LIB")
LIB=$(cd "$DIR" && cd $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM")
done
# Canonicalize by following every symlink of the given name recursively
canonicalize() {
NAME=$1
while [ -h "$NAME" ]; do
DIR=$(dirname -- "$NAME")
SYM=$(readlink "$NAME")
NAME=$(cd "$DIR" && cd $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM")
done
echo "$NAME"
}

LIB=$(dirname -- "$LIB")/
APP=$(dirname $(cd $(dirname $ME) && pwd))
CONSOLE=$(dirname $(canonicalize "$0"))
APP=$(dirname "$CONSOLE")

exec php -q "$LIB"cake.php -working "$APP" "$@"
exec php -q $CONSOLE/cake.php -working "$APP" "$@"

exit;
5 changes: 2 additions & 3 deletions lib/Cake/Cache/Engine/ApcEngine.php
Expand Up @@ -58,9 +58,8 @@ public function init($settings = array()) {
* @return boolean True if the data was successfully cached, false on failure
*/
public function write($key, $value, $duration) {
if ($duration == 0) {
$expires = 0;
} else {
$expires = 0;
if ($duration) {
$expires = time() + $duration;
}
apc_store($key . '_expires', $expires, $duration);
Expand Down
7 changes: 6 additions & 1 deletion lib/Cake/Configure/IniReader.php
Expand Up @@ -176,17 +176,22 @@ protected function _parseNestedValues($values) {
public function dump($filename, $data) {
$result = array();
foreach ($data as $key => $value) {
$isSection = false;
if ($key[0] != '[') {
$result[] = "[$key]";
$isSection = true;
}
if (is_array($value)) {
$keyValues = Hash::flatten($value, '.');
foreach ($keyValues as $k => $v) {
$result[] = "$k = " . $this->_value($v);
}
}
if ($isSection) {
$result[] = '';
}
}
$contents = implode("\n", $result);
$contents = trim(implode("\n", $result));

if (substr($filename, -4) !== '.ini') {
$filename .= '.ini';
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/AclShell.php
Expand Up @@ -602,7 +602,7 @@ protected function _getParams() {
* @return array Variables
*/
protected function _dataVars($type = null) {
if ($type == null) {
if (!$type) {
$type = $this->args[0];
}
$vars = array();
Expand Down
9 changes: 5 additions & 4 deletions lib/Cake/Console/Command/ApiShell.php
Expand Up @@ -69,12 +69,13 @@ public function main() {
$path = $this->paths['core'];
}

if (count($this->args) == 1) {
$file = $type;
$class = Inflector::camelize($type);
} elseif (count($this->args) > 1) {
$count = count($this->args);
if ($count > 1) {
$file = Inflector::underscore($this->args[1]);
$class = Inflector::camelize($this->args[1]);
} elseif ($count) {
$file = $type;
$class = Inflector::camelize($type);
}
$path = $path . Inflector::camelize($type);
$file = $path . '.php';
Expand Down
14 changes: 7 additions & 7 deletions lib/Cake/Console/Command/ConsoleShell.php
Expand Up @@ -183,7 +183,7 @@ public function main($command = null) {
$this->out(" - {$model}");
}
break;
case (preg_match("/^(\w+) bind (\w+) (\w+)/", $command, $tmp) == true):
case preg_match("/^(\w+) bind (\w+) (\w+)/", $command, $tmp):
foreach ($tmp as $data) {
$data = strip_tags($data);
$data = str_replace($this->badCommandChars, "", $data);
Expand All @@ -201,7 +201,7 @@ public function main($command = null) {
$this->out(__d('cake_console', "Please verify you are using valid models and association types"));
}
break;
case (preg_match("/^(\w+) unbind (\w+) (\w+)/", $command, $tmp) == true):
case preg_match("/^(\w+) unbind (\w+) (\w+)/", $command, $tmp):
foreach ($tmp as $data) {
$data = strip_tags($data);
$data = str_replace($this->badCommandChars, "", $data);
Expand Down Expand Up @@ -299,7 +299,7 @@ public function main($command = null) {
$this->out(__d('cake_console', 'Saved record for %s', $modelToSave));
}
break;
case (preg_match("/^(\w+) columns/", $command, $tmp) == true):
case preg_match("/^(\w+) columns/", $command, $tmp):
$modelToCheck = strip_tags(str_replace($this->badCommandChars, "", $tmp[1]));

if ($this->_isValidModel($modelToCheck)) {
Expand All @@ -316,22 +316,22 @@ public function main($command = null) {
$this->out(__d('cake_console', "Please verify that you selected a valid model"));
}
break;
case (preg_match("/^routes\s+reload/i", $command, $tmp) == true):
case preg_match("/^routes\s+reload/i", $command, $tmp):
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."));
break;
}
$this->out(__d('cake_console', "Routes configuration reloaded, %d routes connected", count(Router::$routes)));
break;
case (preg_match("/^routes\s+show/i", $command, $tmp) == true):
case preg_match("/^routes\s+show/i", $command, $tmp):
$this->out(print_r(Hash::combine(Router::$routes, '{n}.template', '{n}.defaults'), true));
break;
case (preg_match("/^route\s+(\(.*\))$/i", $command, $tmp) == true):
case preg_match("/^route\s+(\(.*\))$/i", $command, $tmp):
if ($url = eval('return array' . $tmp[1] . ';')) {
$this->out(Router::url($url));
}
break;
case (preg_match("/^route\s+(.*)/i", $command, $tmp) == true):
case preg_match("/^route\s+(.*)/i", $command, $tmp):
$this->out(var_export(Router::parse($tmp[1]), true));
break;
default:
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Console/Command/Task/ControllerTask.php
Expand Up @@ -396,7 +396,7 @@ public function listAll($useDbConfig = null) {
}
$this->__tables = $this->Model->getAllTables($useDbConfig);

if ($this->interactive == true) {
if ($this->interactive) {
$this->out(__d('cake_console', 'Possible Controllers based on your current database:'));
$this->hr();
$this->_controllerNames = array();
Expand All @@ -420,14 +420,14 @@ public function getName($useDbConfig = null) {
$controllers = $this->listAll($useDbConfig);
$enteredController = '';

while ($enteredController == '') {
while (!$enteredController) {
$enteredController = $this->in(__d('cake_console', "Enter a number from the list above,\ntype in the name of another controller, or 'q' to exit"), null, 'q');
if ($enteredController === 'q') {
$this->out(__d('cake_console', 'Exit'));
return $this->_stop();
}

if ($enteredController == '' || intval($enteredController) > count($controllers)) {
if (!$enteredController || intval($enteredController) > count($controllers)) {
$this->err(__d('cake_console', "The Controller name you supplied was empty,\nor the number you selected was not an option. Please try again."));
$enteredController = '';
}
Expand Down
30 changes: 13 additions & 17 deletions lib/Cake/Console/Command/Task/DbConfigTask.php
Expand Up @@ -93,10 +93,10 @@ protected function _interactive() {
$done = false;
$dbConfigs = array();

while ($done == false) {
while (!$done) {
$name = '';

while ($name == '') {
while (!$name) {
$name = $this->in(__d('cake_console', "Name:"), null, 'default');
if (preg_match('/[^a-z0-9_]/i', $name)) {
$name = '';
Expand All @@ -117,12 +117,12 @@ protected function _interactive() {
}

$host = '';
while ($host == '') {
while (!$host) {
$host = $this->in(__d('cake_console', 'Database Host:'), null, 'localhost');
}

$port = '';
while ($port == '') {
while (!$port) {
$port = $this->in(__d('cake_console', 'Port?'), null, 'n');
}

Expand All @@ -131,16 +131,16 @@ protected function _interactive() {
}

$login = '';
while ($login == '') {
while (!$login) {
$login = $this->in(__d('cake_console', 'User:'), null, 'root');
}
$password = '';
$blankPassword = false;

while ($password == '' && $blankPassword == false) {
while (!$password && !$blankPassword) {
$password = $this->in(__d('cake_console', 'Password:'));

if ($password == '') {
if (!$password) {
$blank = $this->in(__d('cake_console', 'The password you supplied was empty. Use an empty password?'), array('y', 'n'), 'n');
if ($blank == 'y') {
$blankPassword = true;
Expand All @@ -149,20 +149,20 @@ protected function _interactive() {
}

$database = '';
while ($database == '') {
while (!$database) {
$database = $this->in(__d('cake_console', 'Database Name:'), null, 'cake');
}

$prefix = '';
while ($prefix == '') {
while (!$prefix) {
$prefix = $this->in(__d('cake_console', 'Table Prefix?'), null, 'n');
}
if (strtolower($prefix) == 'n') {
$prefix = null;
}

$encoding = '';
while ($encoding == '') {
while (!$encoding) {
$encoding = $this->in(__d('cake_console', 'Table encoding?'), null, 'n');
}
if (strtolower($encoding) == 'n') {
Expand All @@ -171,7 +171,7 @@ protected function _interactive() {

$schema = '';
if ($datasource == 'postgres') {
while ($schema == '') {
while (!$schema) {
$schema = $this->in(__d('cake_console', 'Table schema?'), null, 'n');
}
}
Expand All @@ -181,7 +181,7 @@ protected function _interactive() {

$config = compact('name', 'datasource', 'persistent', 'host', 'login', 'password', 'database', 'prefix', 'encoding', 'port', 'schema');

while ($this->_verify($config) == false) {
while (!$this->_verify($config)) {
$this->_interactive();
}

Expand Down Expand Up @@ -278,11 +278,7 @@ public function bake($configs) {
$info['port'] = null;
}

if ($info['persistent'] === false) {
$info['persistent'] = 'false';
} else {
$info['persistent'] = ($info['persistent'] == true) ? 'true' : 'false';
}
$info['persistent'] = var_export((bool)$info['persistent'], true);

$oldConfigs[] = array(
'name' => $configName,
Expand Down
8 changes: 4 additions & 4 deletions lib/Cake/Console/Command/Task/ExtractTask.php
Expand Up @@ -395,7 +395,7 @@ protected function _parse($functionName, $map) {
$position = $count;
$depth = 0;

while ($depth == 0) {
while (!$depth) {
if ($this->_tokens[$position] == '(') {
$depth++;
} elseif ($this->_tokens[$position] == ')') {
Expand Down Expand Up @@ -482,7 +482,7 @@ protected function _processValidationRules($field, $rules, $file, $domain) {
}

$dims = Hash::dimensions($rules);
if ($dims == 1 || ($dims == 2 && isset($rules['message']))) {
if ($dims === 1 || ($dims === 2 && isset($rules['message']))) {
$rules = array($rules);
}

Expand Down Expand Up @@ -525,7 +525,7 @@ protected function _buildFiles() {
$occurrences[] = $file . ':' . implode(';', $lines);
}
$occurrences = implode("\n#: ", $occurrences);
$header = '#: ' . str_replace($paths, '', $occurrences) . "\n";
$header = '#: ' . str_replace(DS, '/', str_replace($paths, '', $occurrences)) . "\n";

if ($plural === false) {
$sentence = "msgid \"{$msgid}\"\n";
Expand Down Expand Up @@ -593,7 +593,7 @@ protected function _writeFiles() {
);
if (strtoupper($response) === 'N') {
$response = '';
while ($response == '') {
while (!$response) {
$response = $this->in(__d('cake_console', "What would you like to name this file?"), null, 'new_' . $filename);
$File = new File($this->_output . $response);
$filename = $response;
Expand Down
23 changes: 10 additions & 13 deletions lib/Cake/Console/Command/Task/ModelTask.php
Expand Up @@ -473,16 +473,14 @@ public function fieldValidation($fieldName, $metaData, $primaryKey = 'id') {
}

if ($choice != $defaultChoice) {
$validate[$validatorName] = $choice;
if (is_numeric($choice) && isset($this->_validations[$choice])) {
$validate[$validatorName] = $this->_validations[$choice];
} else {
$validate[$validatorName] = $choice;
}
}
if ($this->interactive == true && $choice != $defaultChoice) {
$anotherValidator = 'n';
if ($this->interactive && $choice != $defaultChoice) {
$anotherValidator = $this->in(__d('cake_console', 'Would you like to add another validation rule?'), array('y', 'n'), 'n');
} else {
$anotherValidator = 'n';
}
}
return $validate;
Expand Down Expand Up @@ -584,7 +582,7 @@ public function findHasOneAndMany(Model $model, $associations) {

$pattern = '/_' . preg_quote($model->table, '/') . '|' . preg_quote($model->table, '/') . '_/';
$possibleJoinTable = preg_match($pattern, $otherTable);
if ($possibleJoinTable == true) {
if ($possibleJoinTable) {
continue;
}
foreach ($modelFieldsTemp as $fieldName => $field) {
Expand Down Expand Up @@ -781,7 +779,7 @@ protected function _generatePossibleKeys() {
*/
public function bake($name, $data = array()) {
if (is_object($name)) {
if ($data == false) {
if (!$data) {
$data = array();
$data['associations'] = $this->doAssociations($name);
$data['validate'] = $this->doValidation($name);
Expand Down Expand Up @@ -936,7 +934,7 @@ public function getName($useDbConfig = null) {

$enteredModel = '';

while ($enteredModel == '') {
while (!$enteredModel) {
$enteredModel = $this->in(__d('cake_console', "Enter a number from the list above,\n" .
"type in the name of another model, or 'q' to exit"), null, 'q');

Expand All @@ -945,18 +943,17 @@ public function getName($useDbConfig = null) {
$this->_stop();
}

if ($enteredModel == '' || intval($enteredModel) > count($this->_modelNames)) {
if (!$enteredModel || intval($enteredModel) > count($this->_modelNames)) {
$this->err(__d('cake_console', "The model name you supplied was empty,\n" .
"or the number you selected was not an option. Please try again."));
$enteredModel = '';
}
}
if (intval($enteredModel) > 0 && intval($enteredModel) <= count($this->_modelNames)) {
$currentModelName = $this->_modelNames[intval($enteredModel) - 1];
} else {
$currentModelName = $enteredModel;
return $this->_modelNames[intval($enteredModel) - 1];
}
return $currentModelName;

return $enteredModel;
}

/**
Expand Down

0 comments on commit 8b6cd24

Please sign in to comment.