Browse Source

Stricter treatment of end() returning false.

dereuromark 9 years ago
parent
commit
bcfc7f75ff

+ 4 - 0
src/Controller/Component/AuthComponent.php

@@ -361,6 +361,7 @@ class AuthComponent extends Component
      * @param \Cake\Controller\Controller $controller A reference to the controller object.
      * @return \Cake\Network\Response|null Null if current action is login action
      *   else response object returned by authenticate object or Controller::redirect().
+     * @throws \Cake\Core\Exception\Exception
      */
     protected function _unauthenticated(Controller $controller)
     {
@@ -369,6 +370,9 @@ class AuthComponent extends Component
         }
         $response = $this->response;
         $auth = end($this->_authenticateObjects);
+        if ($auth === false) {
+            throw new Exception('At least one authenticate object must be available.');
+        }
         $result = $auth->unauthenticated($this->request, $response);
         if ($result !== null) {
             return $result;

+ 1 - 1
src/I18n/Formatter/IcuFormatter.php

@@ -66,7 +66,7 @@ class IcuFormatter implements FormatterInterface
             $count = isset($vars['_count']) ? $vars['_count'] : 0;
             unset($vars['_count'], $vars['_singular']);
             $form = PluralRules::calculate($locale, $count);
-            $message = isset($message[$form]) ? $message[$form] : end($message);
+            $message = isset($message[$form]) ? $message[$form] : (string)end($message);
         }
 
         return $this->_formatMessage($locale, $message, $vars);

+ 1 - 1
src/View/ViewBlock.php

@@ -107,7 +107,7 @@ class ViewBlock
 
             return;
         }
-        if (!empty($this->_active)) {
+        if ($this->_active) {
             $mode = end($this->_active);
             $active = key($this->_active);
             $content = ob_get_clean();