Permalink
Browse files

Merge branch '2.3' into type-checks

Conflicts:
	lib/Cake/Error/ExceptionRenderer.php
	lib/Cake/Routing/Dispatcher.php
  • Loading branch information...
2 parents 408e619 + d201030 commit 641ba9f3e61cb33c21068b435136edc8a0379233 @dogmatic69 dogmatic69 committed Oct 24, 2012
Showing with 1,283 additions and 572 deletions.
  1. +18 −18 app/Config/acl.php
  2. +1 −1 app/Config/bootstrap.php
  3. +2 −2 app/Config/core.php
  4. +2 −2 app/Config/routes.php
  5. +5 −1 app/Console/cake
  6. +6 −1 lib/Cake/Configure/IniReader.php
  7. +1 −1 lib/Cake/Console/ShellDispatcher.php
  8. +4 −6 lib/Cake/Console/Templates/default/views/index.ctp
  9. +2 −2 lib/Cake/Console/Templates/skel/Config/bootstrap.php
  10. +1 −1 lib/Cake/Console/Templates/skel/Config/routes.php
  11. +24 −0 lib/Cake/Controller/Component/AuthComponent.php
  12. +1 −1 lib/Cake/Controller/Component/SecurityComponent.php
  13. +1 −1 lib/Cake/Controller/Controller.php
  14. +2 −2 lib/Cake/Core/Configure.php
  15. +0 −1 lib/Cake/Error/ErrorHandler.php
  16. +7 −11 lib/Cake/Error/ExceptionRenderer.php
  17. +0 −7 lib/Cake/I18n/I18n.php
  18. +0 −255 lib/Cake/I18n/Multibyte.php
  19. +24 −15 lib/Cake/Log/CakeLog.php
  20. +11 −7 lib/Cake/Model/Behavior/ContainableBehavior.php
  21. +1 −1 lib/Cake/Model/Behavior/TreeBehavior.php
  22. +24 −7 lib/Cake/Model/Datasource/Database/Mysql.php
  23. +4 −1 lib/Cake/Model/Datasource/Database/Postgres.php
  24. +7 −7 lib/Cake/Model/Datasource/DboSource.php
  25. +5 −5 lib/Cake/Model/Model.php
  26. +1 −1 lib/Cake/Model/Validator/CakeValidationSet.php
  27. +4 −2 lib/Cake/Network/CakeRequest.php
  28. +0 −15 lib/Cake/Routing/Dispatcher.php
  29. +3 −2 lib/Cake/Routing/Route/CakeRoute.php
  30. +34 −3 lib/Cake/Routing/Router.php
  31. +12 −0 lib/Cake/Test/Case/BasicsTest.php
  32. +0 −1 lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php
  33. +1 −0 lib/Cake/Test/Case/Configure/IniReaderTest.php
  34. +4 −4 lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php
  35. +24 −0 lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php
  36. +9 −9 lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php
  37. +2 −2 lib/Cake/Test/Case/Core/AppTest.php
  38. +16 −6 lib/Cake/Test/Case/Event/CakeEventManagerTest.php
  39. +40 −17 lib/Cake/Test/Case/Log/CakeLogTest.php
  40. +13 −0 lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php
  41. +30 −2 lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php
  42. +32 −0 lib/Cake/Test/Case/Model/Behavior/TreeBehaviorUuidTest.php
  43. +75 −1 lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
  44. +12 −1 lib/Cake/Test/Case/Model/ModelReadTest.php
  45. +72 −1 lib/Cake/Test/Case/Model/ModelWriteTest.php
  46. +44 −2 lib/Cake/Test/Case/Network/CakeRequestTest.php
  47. +2 −2 lib/Cake/Test/Case/Network/CakeResponseTest.php
  48. +6 −6 lib/Cake/Test/Case/Routing/DispatcherTest.php
  49. +9 −5 lib/Cake/Test/Case/Routing/RouterTest.php
  50. +11 −11 lib/Cake/Test/Case/Utility/CakeTimeTest.php
  51. +7 −0 lib/Cake/Test/Case/Utility/DebuggerTest.php
  52. +49 −0 lib/Cake/Test/Case/Utility/FolderTest.php
  53. +2 −0 lib/Cake/Test/Case/Utility/InflectorTest.php
  54. +54 −23 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
  55. +32 −0 lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php
  56. +69 −43 lib/Cake/Test/Case/View/Helper/TextHelperTest.php
  57. +2 −2 lib/Cake/Test/Case/View/MediaViewTest.php
  58. +42 −1 lib/Cake/Test/Case/View/ViewTest.php
  59. +1 −1 lib/Cake/Test/test_app/Vendor/css/test_asset.css
  60. +3 −0 lib/Cake/Test/test_app/View/Posts/extend_with_element.ctp
  61. +1 −1 lib/Cake/Test/test_app/View/Themed/TestTheme/webroot/css/test_asset.css
  62. +1 −1 lib/Cake/Test/test_app/webroot/theme/test_theme/css/theme_webroot.css
  63. +1 −1 lib/Cake/Test/test_app/webroot/theme/test_theme/css/webroot_test.css
  64. +2 −0 lib/Cake/TestSuite/CakeTestRunner.php
  65. +8 −2 lib/Cake/TestSuite/Fixture/CakeTestFixture.php
  66. +14 −4 lib/Cake/Utility/Folder.php
  67. +2 −1 lib/Cake/Utility/Inflector.php
  68. +1 −1 lib/Cake/Utility/Set.php
  69. +13 −13 lib/Cake/View/Helper.php
  70. +23 −9 lib/Cake/View/Helper/FormHelper.php
  71. +14 −4 lib/Cake/View/Helper/PaginatorHelper.php
  72. +1 −1 lib/Cake/View/Helper/TextHelper.php
  73. +24 −4 lib/Cake/View/View.php
  74. +44 −6 lib/Cake/View/ViewBlock.php
  75. +1 −1 lib/Cake/basics.php
  76. +263 −4 lib/Cake/bootstrap.php
View
@@ -22,18 +22,18 @@
/**
* Example
* -------
- *
+ *
* Assumptions:
*
- * 1. In your application you created a User model with the following properties:
+ * 1. In your application you created a User model with the following properties:
* username, group_id, password, email, firstname, lastname and so on.
- * 2. You configured AuthComponent to authorize actions via
- * $this->Auth->authorize = array('Actions' => array('actionPath' => 'controllers/'),...)
- *
+ * 2. You configured AuthComponent to authorize actions via
+ * $this->Auth->authorize = array('Actions' => array('actionPath' => 'controllers/'),...)
+ *
* Now, when a user (i.e. jeff) authenticates successfully and requests a controller action (i.e. /invoices/delete)
- * that is not allowed by default (e.g. via $this->Auth->allow('edit') in the Invoices controller) then AuthComponent
- * will ask the configured ACL interface if access is granted. Under the assumptions 1. and 2. this will be
- * done via a call to Acl->check() with
+ * that is not allowed by default (e.g. via $this->Auth->allow('edit') in the Invoices controller) then AuthComponent
+ * will ask the configured ACL interface if access is granted. Under the assumptions 1. and 2. this will be
+ * done via a call to Acl->check() with
*
* array('User' => array('username' => 'jeff', 'group_id' => 4, ...))
*
@@ -42,33 +42,33 @@
* '/controllers/invoices/delete'
*
* as ACO.
- *
+ *
* If the configured map looks like
*
* $config['map'] = array(
* 'User' => 'User/username',
* 'Role' => 'User/group_id',
* );
*
- * then PhpAcl will lookup if we defined a role like User/jeff. If that role is not found, PhpAcl will try to
- * find a definition for Role/4. If the definition isn't found then a default role (Role/default) will be used to
+ * then PhpAcl will lookup if we defined a role like User/jeff. If that role is not found, PhpAcl will try to
+ * find a definition for Role/4. If the definition isn't found then a default role (Role/default) will be used to
* check rules for the given ACO. The search can be expanded by defining aliases in the alias configuration.
* E.g. if you want to use a more readable name than Role/4 in your definitions you can define an alias like
*
* $config['alias'] = array(
* 'Role/4' => 'Role/editor',
* );
- *
+ *
* In the roles configuration you can define roles on the lhs and inherited roles on the rhs:
- *
+ *
* $config['roles'] = array(
* 'Role/admin' => null,
* 'Role/accountant' => null,
* 'Role/editor' => null,
* 'Role/manager' => 'Role/editor, Role/accountant',
* 'User/jeff' => 'Role/manager',
* );
- *
+ *
* In this example manager inherits all rules from editor and accountant. Role/admin doesn't inherit from any role.
* Lets define some rules:
*
@@ -87,10 +87,10 @@
* ),
* );
*
- * Ok, so as jeff inherits from Role/manager he's matched every rule that references User/jeff, Role/manager,
- * Role/editor, Role/accountant and Role/default. However, for jeff, rules for User/jeff are more specific than
+ * Ok, so as jeff inherits from Role/manager he's matched every rule that references User/jeff, Role/manager,
+ * Role/editor, Role/accountant and Role/default. However, for jeff, rules for User/jeff are more specific than
* rules for Role/manager, rules for Role/manager are more specific than rules for Role/editor and so on.
- * This is important when allow and deny rules match for a role. E.g. Role/accountant is allowed
+ * This is important when allow and deny rules match for a role. E.g. Role/accountant is allowed
* controllers/invoices/* but at the same time controllers/invoices/delete is denied. But there is a more
* specific rule defined for Role/manager which is allowed controllers/invoices/delete. However, the most specific
* rule denies access to the delete action explicitly for User/jeff, so he'll be denied access to the resource.
@@ -101,7 +101,7 @@
/**
* The role map defines how to resolve the user record from your application
- * to the roles you defined in the roles configuration.
+ * to the roles you defined in the roles configuration.
*/
$config['map'] = array(
'User' => 'User/username',
View
@@ -2,7 +2,7 @@
/**
* This file is loaded automatically by the app/webroot/index.php file after core.php
*
- * This file should load/create any application wide configuration settings, such as
+ * This file should load/create any application wide configuration settings, such as
* Caching, Logging, loading additional configuration files.
*
* You should also use this file to include any files that provide global functions/constants
View
@@ -226,7 +226,7 @@
Configure::write('Acl.database', 'default');
/**
- * Uncomment this line and correct your server timezone to fix
+ * Uncomment this line and correct your server timezone to fix
* any date & time related errors.
*/
//date_default_timezone_set('UTC');
@@ -238,7 +238,7 @@
* By default File is used, but for improved performance you should use APC.
*
* Note: 'default' and other application caches should be configured in app/Config/bootstrap.php.
- * Please check the comments in boostrap.php for more info on the cache engines available
+ * Please check the comments in boostrap.php for more info on the cache engines available
* and their setttings.
*/
$engine = 'File';
View
@@ -32,13 +32,13 @@
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
/**
- * Load all plugin routes. See the CakePlugin documentation on
+ * Load all plugin routes. See the CakePlugin documentation on
* how to customize the loading of plugin routes.
*/
CakePlugin::routes();
/**
- * Load the CakePHP default routes. Remove this if you do not want to use
+ * Load the CakePHP default routes. Only remove this if you do not want to use
* the built-in default routes.
*/
require CAKE . 'Config' . DS . 'routes.php';
View
@@ -17,7 +17,11 @@
# @license MIT License (http://www.opensource.org/licenses/mit-license.php)
#
################################################################################
-ME=$(readlink -f $0)
+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
@@ -173,17 +173,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';
@@ -215,7 +215,7 @@ public function dispatch() {
return $Shell->main();
}
}
-
+
throw new MissingShellMethodException(array('shell' => $shell, 'method' => $command));
}
@@ -20,14 +20,13 @@
<h2><?php echo "<?php echo __('{$pluralHumanName}'); ?>"; ?></h2>
<table cellpadding="0" cellspacing="0">
<tr>
- <?php foreach ($fields as $field): ?>
+ <?php foreach ($fields as $field): ?>
<th><?php echo "<?php echo \$this->Paginator->sort('{$field}'); ?>"; ?></th>
<?php endforeach; ?>
<th class="actions"><?php echo "<?php echo __('Actions'); ?>"; ?></th>
</tr>
<?php
- echo "<?php
- foreach (\${$pluralVar} as \${$singularVar}): ?>\n";
+ echo "<?php foreach (\${$pluralVar} as \${$singularVar}): ?>\n";
echo "\t<tr>\n";
foreach ($fields as $field) {
$isKey = false;
@@ -47,8 +46,8 @@
echo "\t\t<td class=\"actions\">\n";
echo "\t\t\t<?php echo \$this->Html->link(__('View'), array('action' => 'view', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
- echo "\t\t\t<?php echo \$this->Html->link(__('Edit'), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
- echo "\t\t\t<?php echo \$this->Form->postLink(__('Delete'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
+ echo "\t\t\t<?php echo \$this->Html->link(__('Edit'), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
+ echo "\t\t\t<?php echo \$this->Form->postLink(__('Delete'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
echo "\t\t</td>\n";
echo "\t</tr>\n";
@@ -62,7 +61,6 @@
));
?>"; ?>
</p>
-
<div class="paging">
<?php
echo "<?php\n";
@@ -98,11 +98,11 @@
App::uses('CakeLog', 'Log');
CakeLog::config('debug', array(
'engine' => 'FileLog',
- 'scopes' => array('notice', 'info', 'debug'),
+ 'types' => array('notice', 'info', 'debug'),
'file' => 'debug',
));
CakeLog::config('error', array(
'engine' => 'FileLog',
- 'scopes' => array('warning', 'error', 'critical', 'alert', 'emergency'),
+ 'types' => array('warning', 'error', 'critical', 'alert', 'emergency'),
'file' => 'error',
));
@@ -38,7 +38,7 @@
CakePlugin::routes();
/**
- * Load the CakePHP default routes. Remove this if you do not want to use
+ * Load the CakePHP default routes. Only remove this if you do not want to use
* the built-in default routes.
*/
require CAKE . 'Config' . DS . 'routes.php';
@@ -212,6 +212,15 @@ class AuthComponent extends Component {
public $authError = null;
/**
+ * Controls handling of unauthorized access. By default unauthorized user is
+ * redirected to the referrer url or AuthComponent::$loginAction or '/'.
+ * If set to false a ForbiddenException exception is thrown instead of redirecting.
+ *
+ * @var boolean
+ */
+ public $unauthorizedRedirect = true;
+
+/**
* Controller actions for which user validation is not required.
*
* @var array
@@ -322,6 +331,21 @@ public function startup(Controller $controller) {
return true;
}
+ return $this->_unauthorized($controller);
+ }
+
+/**
+ * Handle unauthorized access attempt
+ *
+ * @param Controller $controller A reference to the controller object
+ * @return boolean Returns false
+ * @throws ForbiddenException
+ */
+ protected function _unauthorized(Controller $controller) {
+ if (!$this->unauthorizedRedirect) {
+ throw new ForbiddenException($this->authError);
+ }
+
$this->flash($this->authError);
$default = '/';
if (!empty($this->loginRedirect)) {
@@ -493,7 +493,7 @@ protected function _validatePost(Controller $controller) {
$fieldList += $lockedFields;
$unlocked = implode('|', $unlocked);
- $check = Security::hash(serialize($fieldList) . $unlocked . Configure::read('Security.salt'));
+ $check = Security::hash(serialize($fieldList) . $unlocked . Configure::read('Security.salt'), 'sha1');
return ($token === $check);
}
@@ -796,7 +796,7 @@ public function redirect($url, $status = null, $exit = true) {
* @return array Array with keys url, status and exit
*/
protected function _parseBeforeRedirect($response, $url, $status, $exit) {
- if (is_array($response) && isset($response[0])) {
+ if (is_array($response) && array_key_exists(0, $response)) {
foreach ($response as $resp) {
if (is_array($resp) && isset($resp['url'])) {
extract($resp, EXTR_OVERWRITE);
@@ -319,10 +319,10 @@ public static function load($key, $config = 'default', $merge = true) {
public static function dump($key, $config = 'default', $keys = array()) {
$reader = self::_getReader($config);
if (!$reader) {
- throw new ConfigureException(__d('cake', 'There is no "%s" adapter.', $config));
+ throw new ConfigureException(__d('cake_dev', 'There is no "%s" adapter.', $config));
}
if (!method_exists($reader, 'dump')) {
- throw new ConfigureException(__d('cake', 'The "%s" adapter, does not have a dump() method.', $config));
+ throw new ConfigureException(__d('cake_dev', 'The "%s" adapter, does not have a dump() method.', $config));
}
$values = self::$_values;
if (!empty($keys) && is_array($keys)) {
@@ -22,7 +22,6 @@
App::uses('Debugger', 'Utility');
App::uses('CakeLog', 'Log');
App::uses('ExceptionRenderer', 'Error');
-App::uses('AppController', 'Controller');
/**
*
@@ -102,10 +102,7 @@ public function __construct(Exception $exception) {
if ($exception instanceof CakeException && !$methodExists) {
$method = '_cakeError';
- if (empty($template)) {
- $template = 'error500';
- }
- if ($template == 'internalError') {
+ if (empty($template) || $template == 'internalError') {
$template = 'error500';
}
} elseif ($exception instanceof PDOException) {
@@ -119,13 +116,12 @@ public function __construct(Exception $exception) {
}
}
- if (!Configure::read('debug')) {
- if ($method == '_cakeError') {
- $method = 'error400';
- }
- if ($code == 500) {
- $method = 'error500';
- }
+ $isNotDebug = (Configure::read('debug') == 0);
+ if ($isNotDebug && $method == '_cakeError') {
+ $method = 'error400';
+ }
+ if ($isNotDebug && $code == 500) {
+ $method = 'error500';
}
$this->template = $template;
$this->method = $method;
View
@@ -24,13 +24,6 @@
App::uses('L10n', 'I18n');
App::uses('Multibyte', 'I18n');
-if (function_exists('mb_internal_encoding')) {
- $encoding = Configure::read('App.encoding');
- if (!empty($encoding)) {
- mb_internal_encoding($encoding);
- }
-}
-
/**
* I18n handles translation of Text and time format strings.
*
Oops, something went wrong.

0 comments on commit 641ba9f

Please sign in to comment.