Browse Source

Merge remote-tracking branch 'upstream/master'

Alexandros Solanos 9 years ago
parent
commit
c0b49d56aa

+ 44 - 0
.varci.yml

@@ -0,0 +1,44 @@
+ruleset:
+  label_defects:
+    name: "Label defects"
+    events: [ issues, pull_request ]
+    label: Defect
+    when:
+      - action = "opened"
+      - body matches "/\[x\] bug/"
+
+  label_enhancements:
+    name: "Label enhancements"
+    events: [ issues, pull_request ]
+    label: Enhancement
+    when:
+      - action = "opened"
+      - body matches "/\[x\] enhancement/"
+
+  label_rfcs:
+    name: "Label RFCs"
+    events: [ issues ]
+    label: RFC
+    when:
+      - action = "opened"
+      - body matches "/\[x\] feature\-discussion/"
+
+  remove_invalid:
+    name: "Remove invalid tag when issue re-opened"
+    events: [ issues, pull_request ]
+    label: -Invalid
+    when:
+      - action = "reopened"
+      - filter(labels, "name") has "Invalid"
+
+  request_missing_version:
+    name: "Request missing version"
+    events: [ issues ]
+    label: "On hold"
+    when:
+      - action = "opened" or action = "re-opened"
+      - body matches "/\[x\] bug/"
+      - 'not(body matches "/CakePHP Version: (\d+\.)?(\d+\.)?(\*|\d+)/")'
+      - 'not(body matches "/CakePHP Version: [0-9a-f]{5,40}/")'
+    comment: '{{ user.login }}, please include the CakePHP version number you are using in your description. It helps us debug your issue.'
+

+ 2 - 2
src/Controller/Component/SecurityComponent.php

@@ -184,7 +184,7 @@ class SecurityComponent extends Component
      *
      * @param \Cake\Controller\Controller $controller Instantiating controller
      * @param string $error Error method
-     * @param \Cake\Controller\Exception\SecurityException $exception Additional debug info describing the cause
+     * @param \Cake\Controller\Exception\SecurityException|null $exception Additional debug info describing the cause
      * @return mixed If specified, controller blackHoleCallback's response, or no return otherwise
      * @see \Cake\Controller\Component\SecurityComponent::$blackHoleCallback
      * @link http://book.cakephp.org/3.0/en/controllers/components/security.html#handling-blackhole-callbacks
@@ -202,7 +202,7 @@ class SecurityComponent extends Component
     /**
      * Check debug status and throw an Exception based on the existing one
      *
-     * @param \Cake\Controller\Exception\SecurityException $exception Additional debug info describing the cause
+     * @param \Cake\Controller\Exception\SecurityException|null $exception Additional debug info describing the cause
      * @throws \Cake\Network\Exception\BadRequestException
      * @return void
      */

+ 0 - 1
src/Controller/ErrorController.php

@@ -15,7 +15,6 @@
 namespace Cake\Controller;
 
 use Cake\Event\Event;
-use Cake\Routing\Router;
 
 /**
  * Error Handling Controller

+ 1 - 1
src/Controller/Exception/SecurityException.php

@@ -56,7 +56,7 @@ class SecurityException extends BadRequestException
     /**
      * Set Reason
      *
-     * @param string $reason Reason details
+     * @param string|null $reason Reason details
      * @return void
      */
     public function setReason($reason = null)

+ 0 - 1
src/Database/Dialect/SqliteDialectTrait.php

@@ -14,7 +14,6 @@
  */
 namespace Cake\Database\Dialect;
 
-use Cake\Database\ExpressionInterface;
 use Cake\Database\Expression\FunctionExpression;
 use Cake\Database\Schema\SqliteSchema;
 use Cake\Database\SqlDialectTrait;

+ 0 - 2
src/Database/Type/ExpressionTypeInterface.php

@@ -14,8 +14,6 @@
  */
 namespace Cake\Database\Type;
 
-use Cake\Database\Driver;
-
 /**
  * An interface used by Type objects to signal whether the value should
  * be converted to an ExpressionInterface instead of a string when sent

+ 0 - 2
src/Database/Type/UuidType.php

@@ -15,8 +15,6 @@
 namespace Cake\Database\Type;
 
 use Cake\Database\Driver;
-use Cake\Database\Type;
-use Cake\Database\TypeInterface;
 use Cake\Utility\Text;
 
 /**

+ 0 - 1
src/Datasource/ModelAwareTrait.php

@@ -15,7 +15,6 @@
 namespace Cake\Datasource;
 
 use Cake\Datasource\Exception\MissingModelException;
-use InvalidArgumentException;
 use UnexpectedValueException;
 
 /**

+ 1 - 1
src/Error/Middleware/ErrorHandlerMiddleware.php

@@ -30,7 +30,7 @@ class ErrorHandlerMiddleware
     /**
      * Constructor
      *
-     * @param string|callable $renderer The renderer or class name
+     * @param string|callable|null $renderer The renderer or class name
      *   to use or a callable factory.
      */
     public function __construct($renderer = null)

+ 0 - 2
src/Http/ActionDispatcher.php

@@ -20,8 +20,6 @@ use Cake\Event\EventListenerInterface;
 use Cake\Http\ControllerFactory;
 use Cake\Network\Request;
 use Cake\Network\Response;
-use Cake\Routing\DispatcherFactory;
-use Cake\Routing\Exception\MissingControllerException;
 use Cake\Routing\Router;
 use LogicException;
 

+ 0 - 1
src/Http/Client/Adapter/Stream.php

@@ -14,7 +14,6 @@
 namespace Cake\Http\Client\Adapter;
 
 use Cake\Core\Exception\Exception;
-use Cake\Http\Client\FormData;
 use Cake\Http\Client\Request;
 use Cake\Http\Client\Response;
 

+ 1 - 1
src/Http/Client/Request.php

@@ -38,7 +38,7 @@ class Request extends Message implements RequestInterface
      * @param string $url The request URL
      * @param string $method The HTTP method to use.
      * @param array $headers The HTTP headers to set.
-     * @param array|string $data The request body to use.
+     * @param array|string|null $data The request body to use.
      */
     public function __construct($url = '', $method = self::METHOD_GET, array $headers = [], $data = null)
     {

+ 0 - 1
src/Http/RequestTransformer.php

@@ -14,7 +14,6 @@
  */
 namespace Cake\Http;
 
-use Cake\Core\Configure;
 use Cake\Network\Request as CakeRequest;
 use Cake\Utility\Hash;
 use Psr\Http\Message\ServerRequestInterface as PsrRequest;

+ 3 - 3
src/Http/Server.php

@@ -62,8 +62,8 @@ class Server
      *   from event listeners.
      * - Run the middleware queue including the application.
      *
-     * @param \Psr\Http\Message\ServerRequestInterface $request  The request to use or null.
-     * @param \Psr\Http\Message\ResponseInterface      $response The response to use or null.
+     * @param \Psr\Http\Message\ServerRequestInterface|null $request The request to use or null.
+     * @param \Psr\Http\Message\ResponseInterface|null $response The response to use or null.
      * @return \Psr\Http\Message\ResponseInterface
      * @throws \RuntimeException When the application does not make a response.
      */
@@ -95,7 +95,7 @@ class Server
      * Emit the response using the PHP SAPI.
      *
      * @param \Psr\Http\Message\ResponseInterface $response The response to emit
-     * @param \Zend\Diactoros\Response\EmitterInterface $emitter The emitter to use.
+     * @param \Zend\Diactoros\Response\EmitterInterface|null $emitter The emitter to use.
      *   When null, a SAPI Stream Emitter will be used.
      * @return void
      */

+ 11 - 2
src/ORM/Association/SelectableAssociationTrait.php

@@ -134,12 +134,21 @@ trait SelectableAssociationTrait
         if (empty($select)) {
             return;
         }
-        $missingFields = array_diff($key, $select) !== [];
+        $missingKey = function ($fieldList, $key) {
+            foreach ($key as $keyField) {
+                if (!in_array($keyField, $fieldList, true)) {
+                    return true;
+                }
+            }
+
+            return false;
+        };
 
+        $missingFields = $missingKey($select, $key);
         if ($missingFields) {
             $driver = $fetchQuery->connection()->driver();
             $quoted = array_map([$driver, 'quoteIdentifier'], $key);
-            $missingFields = array_diff($quoted, $select) !== [];
+            $missingFields = $missingKey($select, $quoted);
         }
 
         if ($missingFields) {

+ 0 - 2
src/Routing/Dispatcher.php

@@ -14,13 +14,11 @@
  */
 namespace Cake\Routing;
 
-use Cake\Controller\Controller;
 use Cake\Event\EventDispatcherTrait;
 use Cake\Event\EventListenerInterface;
 use Cake\Http\ActionDispatcher;
 use Cake\Network\Request;
 use Cake\Network\Response;
-use LogicException;
 
 /**
  * Dispatcher converts Requests into controller actions. It uses the dispatched Request

+ 0 - 3
src/Routing/Filter/ControllerFactoryFilter.php

@@ -14,12 +14,9 @@
  */
 namespace Cake\Routing\Filter;
 
-use Cake\Core\App;
 use Cake\Event\Event;
 use Cake\Http\ControllerFactory;
 use Cake\Routing\DispatcherFilter;
-use Cake\Utility\Inflector;
-use ReflectionClass;
 
 /**
  * A dispatcher filter that builds the controller to dispatch

+ 1 - 0
src/Routing/Filter/RoutingFilter.php

@@ -58,6 +58,7 @@ class RoutingFilter extends DispatcherFilter
                 $request->addParams($params);
             }
         } catch (RedirectException $e) {
+            $event->stopPropagation();
             $response = $event->data['response'];
             $response->statusCode($e->getCode());
             $response->header('Location', $e->getMessage());

+ 0 - 1
src/Shell/CacheShell.php

@@ -18,7 +18,6 @@ use Cake\Cache\Cache;
 use Cake\Cache\Engine\ApcEngine;
 use Cake\Cache\Engine\WincacheEngine;
 use Cake\Console\Shell;
-use Cake\Core\Configure;
 
 /**
  * Cache Shell.

+ 0 - 3
src/TestSuite/IntegrationTestCase.php

@@ -16,11 +16,9 @@ namespace Cake\TestSuite;
 use Cake\Core\Configure;
 use Cake\Database\Exception as DatabaseException;
 use Cake\Network\Session;
-use Cake\Routing\DispatcherFactory;
 use Cake\Routing\Router;
 use Cake\TestSuite\LegacyRequestDispatcher;
 use Cake\TestSuite\MiddlewareDispatcher;
-use Cake\TestSuite\Stub\Response;
 use Cake\Utility\CookieCryptTrait;
 use Cake\Utility\Hash;
 use Cake\Utility\Security;
@@ -29,7 +27,6 @@ use Cake\View\Helper\SecureFieldTokenTrait;
 use Exception;
 use LogicException;
 use PHPUnit_Exception;
-use PHPUnit_Framework_Constraint_IsEqual;
 
 /**
  * A test case class intended to make integration tests of

+ 0 - 2
src/TestSuite/LegacyRequestDispatcher.php

@@ -13,9 +13,7 @@
  */
 namespace Cake\TestSuite;
 
-use Cake\Core\Configure;
 use Cake\Network\Request;
-use Cake\Network\Session;
 use Cake\Routing\DispatcherFactory;
 use Cake\TestSuite\Stub\Response;
 

+ 1 - 1
src/TestSuite/MiddlewareDispatcher.php

@@ -56,7 +56,7 @@ class MiddlewareDispatcher
      * Constructor
      *
      * @param \Cake\TestSuite\IntegrationTestCase $test The test case to run.
-     * @param string $class The application class name. Defaults to App\Application.
+     * @param string|null $class The application class name. Defaults to App\Application.
      * @param array|null $constructorArgs The constructor arguments for your application class.
      *   Defaults to `['./config']`
      */

+ 2 - 2
src/TestSuite/TestCase.php

@@ -146,7 +146,7 @@ abstract class TestCase extends PHPUnit_Framework_TestCase
      * Asserts that a global event was fired. You must track events in your event manager for this assertion to work
      *
      * @param string $name Event name
-     * @param EventManager $eventManager Event manager to check, defaults to global event manager
+     * @param EventManager|null $eventManager Event manager to check, defaults to global event manager
      * @param string $message Assertion failure message
      * @return void
      */
@@ -166,7 +166,7 @@ abstract class TestCase extends PHPUnit_Framework_TestCase
      * @param string $name Event name
      * @param string $dataKey Data key
      * @param string $dataValue Data value
-     * @param EventManager $eventManager Event manager to check, defaults to global event manager
+     * @param EventManager|null $eventManager Event manager to check, defaults to global event manager
      * @param string $message Assertion failure message
      * @return void
      */

+ 26 - 0
tests/TestCase/ORM/QueryRegressionTest.php

@@ -948,6 +948,32 @@ class QueryRegressionTest extends TestCase
     }
 
     /**
+     * Tests that find() and contained associations using computed fields doesn't error out.
+     *
+     * @see https://github.com/cakephp/cakephp/issues/9326
+     * @return void
+     */
+    public function testContainWithComputedField()
+    {
+        $this->loadFixtures('Comments', 'Users');
+        $table = TableRegistry::get('Users');
+        $table->hasMany('Comments');
+
+        $query = $table->find()->contain([
+            'Comments' => function ($q) {
+                return $q->select([
+                    'concat' => $q->func()->concat(['red', 'blue']),
+                    'user_id'
+                ]);
+            }])
+            ->where(['Users.id' => 2]);
+
+        $results = $query->toArray();
+        $this->assertCount(1, $results);
+        $this->assertEquals('redblue', $results[0]->comments[0]->concat);
+    }
+
+    /**
      * Tests that using matching and selecting no fields for that association
      * will no trigger any errors and fetch the right results
      *

+ 1 - 0
tests/TestCase/Routing/Filter/RoutingFilterTest.php

@@ -90,6 +90,7 @@ class RoutingFilterTest extends TestCase
         $this->assertInstanceOf('Cake\Network\Response', $response);
         $this->assertSame('http://localhost/articles', $response->header()['Location']);
         $this->assertSame(301, $response->statusCode());
+        $this->assertTrue($event->isStopped());
     }
 
     /**