Permalink
Browse files

Merge branch '2.3' into type-checks

Conflicts:
	lib/Cake/Console/Command/Task/ModelTask.php
	lib/Cake/Controller/Component/RequestHandlerComponent.php
	lib/Cake/Model/Datasource/Database/Mysql.php
	lib/Cake/Utility/CakeNumber.php
  • Loading branch information...
2 parents 1b36853 + e1a0ce7 commit 408e619c9fa6f114ca0531713e1df996165637eb @dogmatic69 dogmatic69 committed Oct 1, 2012
Showing with 1,411 additions and 650 deletions.
  1. +1 −1 app/webroot/index.php
  2. +2 −2 lib/Cake/Cache/Cache.php
  3. +1 −0 lib/Cake/Cache/Engine/WincacheEngine.php
  4. +6 −3 lib/Cake/Configure/IniReader.php
  5. +2 −2 lib/Cake/Console/Command/Task/ControllerTask.php
  6. +4 −1 lib/Cake/Console/Command/Task/DbConfigTask.php
  7. +1 −1 lib/Cake/Console/Command/Task/ExtractTask.php
  8. +5 −5 lib/Cake/Console/Command/Task/ModelTask.php
  9. +4 −0 lib/Cake/Console/ConsoleErrorHandler.php
  10. +4 −3 lib/Cake/Console/ShellDispatcher.php
  11. +6 −6 lib/Cake/Console/Templates/default/actions/controller_actions.ctp
  12. +1 −1 lib/Cake/Console/Templates/skel/View/Errors/error400.ctp
  13. +1 −1 lib/Cake/Console/Templates/skel/View/Errors/error500.ctp
  14. +1 −1 lib/Cake/Console/Templates/skel/webroot/index.php
  15. +1 −1 lib/Cake/Console/Templates/skel/webroot/test.php
  16. +0 −2 lib/Cake/Controller/Component/Acl/PhpAcl.php
  17. +1 −1 lib/Cake/Controller/Component/AuthComponent.php
  18. +15 −5 lib/Cake/Controller/Component/CookieComponent.php
  19. +55 −59 lib/Cake/Controller/Component/RequestHandlerComponent.php
  20. +13 −7 lib/Cake/Controller/Component/SecurityComponent.php
  21. +0 −1 lib/Cake/Controller/Controller.php
  22. +13 −1 lib/Cake/Core/Configure.php
  23. +3 −3 lib/Cake/Error/ExceptionRenderer.php
  24. +4 −4 lib/Cake/I18n/I18n.php
  25. +46 −40 lib/Cake/I18n/L10n.php
  26. +1 −1 lib/Cake/I18n/Multibyte.php
  27. +19 −6 lib/Cake/Model/Behavior/TranslateBehavior.php
  28. +5 −5 lib/Cake/Model/CakeSchema.php
  29. +2 −5 lib/Cake/Model/Datasource/CakeSession.php
  30. +18 −23 lib/Cake/Model/Datasource/Database/Mysql.php
  31. +23 −2 lib/Cake/Model/Datasource/Database/Postgres.php
  32. +8 −5 lib/Cake/Model/Datasource/Database/Sqlite.php
  33. +4 −1 lib/Cake/Model/Datasource/Database/Sqlserver.php
  34. +25 −9 lib/Cake/Model/Datasource/DboSource.php
  35. +18 −7 lib/Cake/Model/Model.php
  36. +1 −2 lib/Cake/Model/Validator/CakeValidationRule.php
  37. +1 −1 lib/Cake/Model/Validator/CakeValidationSet.php
  38. +11 −1 lib/Cake/Network/CakeRequest.php
  39. +6 −5 lib/Cake/Network/CakeResponse.php
  40. +1 −1 lib/Cake/Network/Email/CakeEmail.php
  41. +23 −6 lib/Cake/Network/Email/MailTransport.php
  42. +45 −34 lib/Cake/Routing/Filter/AssetDispatcher.php
  43. +1 −1 lib/Cake/Routing/Route/CakeRoute.php
  44. +1 −1 lib/Cake/Routing/Router.php
  45. +11 −10 lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php
  46. +2 −2 lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php
  47. +1 −1 lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php
  48. +17 −0 lib/Cake/Test/Case/Console/ConsoleErrorHandlerTest.php
  49. +1 −1 lib/Cake/Test/Case/Controller/Component/Acl/PhpAclTest.php
  50. +3 −0 lib/Cake/Test/Case/Controller/Component/Auth/BlowfishAuthenticateTest.php
  51. +57 −1 lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php
  52. +54 −0 lib/Cake/Test/Case/Core/ConfigureTest.php
  53. +43 −20 lib/Cake/Test/Case/Error/ExceptionRendererTest.php
  54. +2 −2 lib/Cake/Test/Case/I18n/I18nTest.php
  55. +62 −58 lib/Cake/Test/Case/I18n/L10nTest.php
  56. +58 −58 lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php
  57. +17 −0 lib/Cake/Test/Case/Model/CakeSchemaTest.php
  58. +1 −1 lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php
  59. +32 −15 lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
  60. +22 −0 lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php
  61. +8 −0 lib/Cake/Test/Case/Model/ModelIntegrationTest.php
  62. +39 −0 lib/Cake/Test/Case/Network/CakeRequestTest.php
  63. +7 −5 lib/Cake/Test/Case/Network/CakeSocketTest.php
  64. +8 −4 lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
  65. +84 −0 lib/Cake/Test/Case/Network/Email/MailTransportTest.php
  66. +24 −0 lib/Cake/Test/Case/Routing/RouterTest.php
  67. +2 −2 lib/Cake/Test/Case/TestSuite/CakeTestSuiteTest.php
  68. +91 −0 lib/Cake/Test/Case/Utility/CakeNumberTest.php
  69. +15 −0 lib/Cake/Test/Case/Utility/CakeTimeTest.php
  70. +1 −2 lib/Cake/Test/Case/Utility/DebuggerTest.php
  71. +5 −5 lib/Cake/Test/Case/Utility/FileTest.php
  72. +4 −4 lib/Cake/Test/Case/Utility/FolderTest.php
  73. +18 −1 lib/Cake/Test/Case/Utility/SecurityTest.php
  74. +31 −12 lib/Cake/Test/Case/Utility/ValidationTest.php
  75. +74 −79 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
  76. +17 −1 lib/Cake/Test/Case/View/ViewTest.php
  77. +1 −1 lib/Cake/Test/test_app/Error/TestAppsExceptionRenderer.php
  78. +1 −1 lib/Cake/Test/test_app/View/Errors/error400.ctp
  79. +1 −1 lib/Cake/Test/test_app/View/Errors/error500.ctp
  80. +33 −6 lib/Cake/TestSuite/Fixture/CakeTestFixture.php
  81. +82 −27 lib/Cake/Utility/CakeNumber.php
  82. +5 −12 lib/Cake/Utility/CakeTime.php
  83. +1 −0 lib/Cake/Utility/ClassRegistry.php
  84. +3 −4 lib/Cake/Utility/Debugger.php
  85. +1 −1 lib/Cake/Utility/Folder.php
  86. +0 −1 lib/Cake/Utility/Hash.php
  87. +2 −2 lib/Cake/Utility/Inflector.php
  88. +22 −0 lib/Cake/Utility/Validation.php
  89. +1 −1 lib/Cake/Utility/Xml.php
  90. +7 −1 lib/Cake/View/Errors/missing_connection.ctp
  91. +1 −1 lib/Cake/View/Helper.php
  92. +1 −1 lib/Cake/View/Helper/CacheHelper.php
  93. +20 −16 lib/Cake/View/Helper/FormHelper.php
  94. +4 −4 lib/Cake/View/Helper/HtmlHelper.php
  95. +1 −1 lib/Cake/View/Helper/JsBaseEngineHelper.php
  96. +0 −1 lib/Cake/View/Helper/MootoolsEngineHelper.php
  97. +1 −1 lib/Cake/View/Helper/PaginatorHelper.php
  98. +0 −1 lib/Cake/View/Helper/PrototypeEngineHelper.php
  99. +1 −1 lib/Cake/View/Helper/RssHelper.php
  100. +0 −1 lib/Cake/View/Helper/TimeHelper.php
  101. +5 −10 lib/Cake/View/View.php
  102. +3 −3 lib/Cake/View/ViewBlock.php
View
@@ -94,4 +94,4 @@
App::uses('Dispatcher', 'Routing');
$Dispatcher = new Dispatcher();
-$Dispatcher->dispatch(new CakeRequest(), new CakeResponse(array('charset' => Configure::read('App.encoding'))));
+$Dispatcher->dispatch(new CakeRequest(), new CakeResponse());
View
@@ -366,7 +366,7 @@ public static function increment($key, $offset = 1, $config = 'default') {
}
$key = self::$_engines[$config]->key($key);
- if (!$key || !is_integer($offset) || $offset < 0) {
+ if (!$key || !is_int($offset) || $offset < 0) {
return false;
}
$success = self::$_engines[$config]->increment($settings['prefix'] . $key, $offset);
@@ -394,7 +394,7 @@ public static function decrement($key, $offset = 1, $config = 'default') {
}
$key = self::$_engines[$config]->key($key);
- if (!$key || !is_integer($offset) || $offset < 0) {
+ if (!$key || !is_int($offset) || $offset < 0) {
return false;
}
$success = self::$_engines[$config]->decrement($settings['prefix'] . $key, $offset);
@@ -183,6 +183,7 @@ public function groups() {
* @return boolean success
**/
public function clearGroup($group) {
+ $success = null;
wincache_ucache_inc($this->settings['prefix'] . $group, 1, $success);
return $success;
}
@@ -72,11 +72,14 @@ class IniReader implements ConfigReaderInterface {
* Build and construct a new ini file parser. The parser can be used to read
* ini files that are on the filesystem.
*
- * @param string $path Path to load ini config files from.
+ * @param string $path Path to load ini config files from. Defaults to APP . 'Config' . DS
* @param string $section Only get one section, leave null to parse and fetch
* all sections in the ini file.
*/
- public function __construct($path, $section = null) {
+ public function __construct($path = null, $section = null) {
+ if (!$path) {
+ $path = APP . 'Config' . DS;
+ }
$this->_path = $path;
$this->_section = $section;
}
@@ -180,7 +183,7 @@ public function dump($filename, $data) {
}
}
}
- $contents = join("\n", $result);
+ $contents = implode("\n", $result);
if (substr($filename, -4) !== '.ini') {
$filename .= '.ini';
@@ -349,7 +349,7 @@ public function bakeTest($className) {
public function doHelpers() {
return $this->_doPropertyChoices(
__d('cake_console', "Would you like this controller to use other helpers\nbesides HtmlHelper and FormHelper?"),
- __d('cake_console', "Please provide a comma separated list of the other\nhelper names you'd like to use.\nExample: 'Ajax, Javascript, Time'")
+ __d('cake_console', "Please provide a comma separated list of the other\nhelper names you'd like to use.\nExample: 'Text, Js, Time'")
);
}
@@ -432,7 +432,7 @@ public function getName($useDbConfig = null) {
}
}
- if (intval($enteredController) > 0 && intval($enteredController) <= count($controllers) ) {
+ if (intval($enteredController) > 0 && intval($enteredController) <= count($controllers)) {
$controllerName = $controllers[intval($enteredController) - 1];
} else {
$controllerName = Inflector::camelize($enteredController);
@@ -311,8 +311,11 @@ public function bake($configs) {
$config = array_merge($this->_defaultConfig, $config);
extract($config);
+ if (strpos($datasource, 'Database/') === false) {
+ $datasource = "Database/{$datasource}";
+ }
$out .= "\tpublic \${$name} = array(\n";
- $out .= "\t\t'datasource' => 'Database/{$datasource}',\n";
+ $out .= "\t\t'datasource' => '{$datasource}',\n";
$out .= "\t\t'persistent' => {$persistent},\n";
$out .= "\t\t'host' => '{$host}',\n";
@@ -245,7 +245,7 @@ protected function _addTranslation($domain, $msgid, $details = array()) {
if (empty($this->_translations[$domain][$msgid])) {
$this->_translations[$domain][$msgid] = array(
'msgid_plural' => false
- );
+ );
}
if (isset($details['msgid_plural'])) {
@@ -686,7 +686,7 @@ public function doMoreAssociations(Model $model, $associations) {
$prompt = __d('cake_console', 'Would you like to define some additional model associations?');
$wannaDoMoreAssoc = $this->in($prompt, array('y', 'n'), 'n');
$possibleKeys = $this->_generatePossibleKeys();
- while (strtolower($wannaDoMoreAssoc) == 'y') {
+ while (strtolower($wannaDoMoreAssoc) === 'y') {
$assocs = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
$this->out(__d('cake_console', 'What is the association type?'));
$assocType = intval($this->inOptions($assocs, __d('cake_console', 'Enter a number')));
@@ -696,9 +696,9 @@ public function doMoreAssociations(Model $model, $associations) {
$this->hr();
$alias = $this->in(__d('cake_console', 'What is the alias for this association?'));
- $className = $this->in(__d('cake_console', 'What className will %s use?', $alias), null, $alias );
+ $className = $this->in(__d('cake_console', 'What className will %s use?', $alias), null, $alias);
- if (!$assocType) {
+ if ($assocType === 0) {
if (!empty($possibleKeys[$model->table])) {
$showKeys = $possibleKeys[$model->table];
} else {
@@ -731,7 +731,7 @@ public function doMoreAssociations(Model $model, $associations) {
if (!isset($foreignKey)) {
$foreignKey = $this->in(__d('cake_console', 'What is the foreignKey? Specify your own.'), null, $suggestedForeignKey);
}
- if ($assocType == 3) {
+ if ($assocType === 3) {
$associationForeignKey = $this->in(__d('cake_console', 'What is the associationForeignKey?'), null, $this->_modelKey($model->name));
$joinTable = $this->in(__d('cake_console', 'What is the joinTable?'));
}
@@ -741,7 +741,7 @@ public function doMoreAssociations(Model $model, $associations) {
$associations[$assocs[$assocType]][$i]['alias'] = $alias;
$associations[$assocs[$assocType]][$i]['className'] = $className;
$associations[$assocs[$assocType]][$i]['foreignKey'] = $foreignKey;
- if ($assocType == 3) {
+ if ($assocType === 3) {
$associations[$assocs[$assocType]][$i]['associationForeignKey'] = $associationForeignKey;
$associations[$assocs[$assocType]][$i]['joinTable'] = $joinTable;
}
@@ -84,6 +84,10 @@ public function handleError($code, $description, $file = null, $line = null, $co
if (!Configure::read('debug')) {
CakeLog::write($log, $message);
}
+
+ if ($log === LOG_ERR) {
+ $this->_stop(1);
+ }
}
/**
@@ -160,11 +160,11 @@ public function setErrorHandlers() {
$errorHandler = new ConsoleErrorHandler();
if (empty($error['consoleHandler'])) {
$error['consoleHandler'] = array($errorHandler, 'handleError');
- Configure::write('error', $error);
+ Configure::write('Error', $error);
}
if (empty($exception['consoleHandler'])) {
$exception['consoleHandler'] = array($errorHandler, 'handleException');
- Configure::write('exception', $exception);
+ Configure::write('Exception', $exception);
}
set_exception_handler($exception['consoleHandler']);
set_error_handler($error['consoleHandler'], Configure::read('Error.level'));
@@ -215,7 +215,8 @@ public function dispatch() {
return $Shell->main();
}
}
- throw new MissingShellMethodException(array('shell' => $shell, 'method' => $arg));
+
+ throw new MissingShellMethodException(array('shell' => $shell, 'method' => $command));
}
/**
@@ -36,11 +36,11 @@
* @return void
*/
public function <?php echo $admin ?>view($id = null) {
- $this-><?php echo $currentModelName; ?>->id = $id;
- if (!$this-><?php echo $currentModelName; ?>->exists()) {
+ if (!$this-><?php echo $currentModelName; ?>->exists($id)) {
throw new NotFoundException(__('Invalid <?php echo strtolower($singularHumanName); ?>'));
}
- $this->set('<?php echo $singularName; ?>', $this-><?php echo $currentModelName; ?>->read(null, $id));
+ $options = array('conditions' => array('<?php echo $currentModelName; ?>.' . $this-><?php echo $currentModelName; ?>->primaryKey => $id));
+ $this->set('<?php echo $singularName; ?>', $this-><?php echo $currentModelName; ?>->find('first', $options));
}
<?php $compact = array(); ?>
@@ -91,8 +91,7 @@
* @return void
*/
public function <?php echo $admin; ?>edit($id = null) {
- $this-><?php echo $currentModelName; ?>->id = $id;
- if (!$this-><?php echo $currentModelName; ?>->exists()) {
+ if (!$this-><?php echo $currentModelName; ?>->exists($id)) {
throw new NotFoundException(__('Invalid <?php echo strtolower($singularHumanName); ?>'));
}
if ($this->request->is('post') || $this->request->is('put')) {
@@ -109,7 +108,8 @@
<?php endif; ?>
}
} else {
- $this->request->data = $this-><?php echo $currentModelName; ?>->read(null, $id);
+ $options = array('conditions' => array('<?php echo $currentModelName; ?>.' . $this-><?php echo $currentModelName; ?>->primaryKey => $id));
+ $this->request->data = $this-><?php echo $currentModelName; ?>->find('first', $options);
}
<?php
foreach (array('belongsTo', 'hasAndBelongsToMany') as $assoc):
@@ -25,7 +25,7 @@
); ?>
</p>
<?php
-if (Configure::read('debug') > 0 ):
+if (Configure::read('debug') > 0):
echo $this->element('exception_stack_trace');
endif;
?>
@@ -22,7 +22,7 @@
<?php echo __d('cake', 'An Internal Error Has Occurred.'); ?>
</p>
<?php
-if (Configure::read('debug') > 0 ):
+if (Configure::read('debug') > 0):
echo $this->element('exception_stack_trace');
endif;
?>
@@ -98,5 +98,5 @@
$Dispatcher = new Dispatcher();
$Dispatcher->dispatch(
new CakeRequest(),
- new CakeResponse(array('charset' => Configure::read('App.encoding')))
+ new CakeResponse()
);
@@ -86,7 +86,7 @@
}
if (Configure::read('debug') < 1) {
- die(__d('cake_dev', 'Debug setting does not allow access to this url.'));
+ exit(__d('cake_dev', 'Debug setting does not allow access to this url.'));
}
require_once CAKE . 'TestSuite' . DS . 'CakeTestSuiteDispatcher.php';
@@ -318,10 +318,8 @@ public function resolve($aco) {
* @return void
*/
public function build(array $allow, array $deny = array()) {
- $stack = array();
$this->_tree = array();
$tree = array();
- $root = &$tree;
foreach ($allow as $dotPath => $aros) {
if (is_string($aros)) {
@@ -327,7 +327,7 @@ public function startup(Controller $controller) {
if (!empty($this->loginRedirect)) {
$default = $this->loginRedirect;
}
- $controller->redirect($controller->referer($default), null, true);
+ $controller->redirect($controller->referer($default, true), null, true);
return false;
}
@@ -177,7 +177,7 @@ public function __construct(ComponentCollection $collection, $settings = array()
if ($controller && isset($controller->response)) {
$this->_response = $controller->response;
} else {
- $this->_response = new CakeResponse(array('charset' => Configure::read('App.encoding')));
+ $this->_response = new CakeResponse();
}
}
@@ -191,9 +191,6 @@ public function startup(Controller $controller) {
$this->_expire($this->time);
$this->_values[$this->name] = array();
- if (isset($_COOKIE[$this->name])) {
- $this->_values[$this->name] = $this->_decrypt($_COOKIE[$this->name]);
- }
}
/**
@@ -282,6 +279,19 @@ public function read($key = null) {
}
/**
+ * Returns true if given variable is set in cookie.
+ *
+ * @param string $var Variable name to check for
+ * @return boolean True if variable is there
+ */
+ public function check($key = null) {
+ if (empty($key)) {
+ return false;
+ }
+ return $this->read($key) !== null;
+ }
+
+/**
* Delete a cookie value
*
* Optional [Name.], required key
@@ -385,7 +395,7 @@ protected function _expire($expires = null) {
return $this->_expires = 0;
}
- if (is_integer($expires) || is_numeric($expires)) {
+ if (is_int($expires) || is_numeric($expires)) {
return $this->_expires = $now + intval($expires);
}
return $this->_expires = strtotime($expires, $now);
Oops, something went wrong.

0 comments on commit 408e619

Please sign in to comment.