Browse Source

Merge branch 'master' of github.com:cakephp/cakephp

mark_story 8 years ago
parent
commit
85bd33d325

+ 1 - 1
src/Controller/Component/RequestHandlerComponent.php

@@ -506,7 +506,7 @@ class RequestHandlerComponent extends Component
         $acceptRaw = $request->parseAccept();
 
         if (empty($acceptRaw)) {
-            return $this->ext;
+            return $type ? $type === $this->ext : $this->ext;
         }
         $accepts = $response->mapType(array_shift($acceptRaw));
 

+ 3 - 3
src/ORM/Association.php

@@ -120,7 +120,7 @@ abstract class Association
      * A list of conditions to be always included when fetching records from
      * the target association
      *
-     * @var array
+     * @var array|callable
      */
     protected $_conditions = [];
 
@@ -456,7 +456,7 @@ abstract class Association
      * Sets a list of conditions to be always included when fetching records from
      * the target association.
      *
-     * @param array $conditions list of conditions to be used
+     * @param array|callable $conditions list of conditions to be used
      * @see \Cake\Database\Query::where() for examples on the format of the array
      * @return $this
      */
@@ -472,7 +472,7 @@ abstract class Association
      * the target association.
      *
      * @see \Cake\Database\Query::where() for examples on the format of the array
-     * @return array
+     * @return array|callable
      */
     public function getConditions()
     {

+ 1 - 1
src/ORM/EagerLoader.php

@@ -398,7 +398,7 @@ class EagerLoader
 
             $pointer += [$table => []];
 
-            if (isset($options['queryBuilder']) && isset($pointer[$table]['queryBuilder'])) {
+            if (isset($options['queryBuilder'], $pointer[$table]['queryBuilder'])) {
                 $first = $pointer[$table]['queryBuilder'];
                 $second = $options['queryBuilder'];
                 $options['queryBuilder'] = function ($query) use ($first, $second) {

+ 1 - 1
src/Validation/Validation.php

@@ -1231,7 +1231,7 @@ class Validation
         if (isset($options['width'])) {
             $validWidth = self::comparison($width, $options['width'][0], $options['width'][1]);
         }
-        if (isset($validHeight) && isset($validWidth)) {
+        if (isset($validHeight, $validWidth)) {
             return ($validHeight && $validWidth);
         }
         if (isset($validHeight)) {

+ 4 - 0
tests/TestCase/Controller/Component/RequestHandlerComponentTest.php

@@ -898,6 +898,10 @@ class RequestHandlerComponentTest extends TestCase
         $this->request->env('HTTP_ACCEPT', '*/*;q=0.5');
         $this->assertEquals('html', $this->RequestHandler->prefers());
         $this->assertFalse($this->RequestHandler->prefers('rss'));
+
+        $this->Controller->request = $this->request->withEnv('HTTP_ACCEPT', null);
+        $this->RequestHandler->ext = 'json';
+        $this->assertFalse($this->RequestHandler->prefers('xml'));
     }
 
     /**