Browse Source

Merge branch 'master' into 3.next

Mark Story 8 years ago
parent
commit
eb36fdf6e7

File diff suppressed because it is too large
+ 213 - 701
config/cacert.pem


+ 2 - 1
src/ORM/Association.php

@@ -1191,7 +1191,8 @@ abstract class Association
         }
 
         if ($autoFields === true) {
-            $fields = array_merge((array)$fields, $target->getSchema()->columns());
+            $fields = array_filter((array)$fields);
+            $fields = array_merge($fields, $target->getSchema()->columns());
         }
 
         if ($fields) {

+ 11 - 6
src/Routing/Router.php

@@ -640,18 +640,17 @@ class Router
             return $output;
         }
         if (is_array($url)) {
+            if (isset($url['_ssl'])) {
+                $url['_scheme'] = ($url['_ssl'] === true) ? 'https' : 'http';
+            }
+
             if (isset($url['_full']) && $url['_full'] === true) {
                 $full = true;
-                unset($url['_full']);
             }
             if (isset($url['#'])) {
                 $frag = '#' . $url['#'];
-                unset($url['#']);
-            }
-            if (isset($url['_ssl'])) {
-                $url['_scheme'] = ($url['_ssl'] === true) ? 'https' : 'http';
-                unset($url['_ssl']);
             }
+            unset($url['_ssl'], $url['_full'], $url['#']);
 
             $url = static::_applyUrlFilters($url);
 
@@ -676,6 +675,12 @@ class Router
                 ];
             }
 
+            // If a full URL is requested with a scheme the host should default
+            // to App.fullBaseUrl to avoid corrupt URLs
+            if ($full && isset($url['_scheme']) && !isset($url['_host'])) {
+                $url['_host'] = parse_url(static::fullBaseUrl(), PHP_URL_HOST);
+            }
+
             $output = static::$_collection->match($url, static::$_requestContext + ['params' => $params]);
         } else {
             $plainString = (

+ 19 - 0
tests/TestCase/ORM/QueryTest.php

@@ -3318,6 +3318,25 @@ class QueryTest extends TestCase
     }
 
     /**
+     * Tests that leftJoinWith() can be used with autofields()
+     *
+     * @return void
+     */
+    public function testLeftJoinWithAutoFields()
+    {
+        $table = TableRegistry::get('articles');
+        $table->belongsTo('authors');
+
+        $results = $table
+            ->find()
+            ->leftJoinWith('authors', function ($q) {
+                return $q->enableAutoFields(true);
+            })
+            ->all();
+        $this->assertCount(3, $results);
+    }
+
+    /**
      * Tests innerJoinWith()
      *
      * @return void

+ 40 - 0
tests/TestCase/Routing/RouterTest.php

@@ -2075,6 +2075,46 @@ class RouterTest extends TestCase
     }
 
     /**
+     * Test that the _ssl + _full options work together.
+     *
+     * @return void
+     */
+    public function testGenerationWithSslAndFullOption()
+    {
+        Configure::write('App.fullBaseUrl', 'http://app.localhost');
+        Router::connect('/:controller/:action/*');
+
+        $request = new ServerRequest([
+            'environment' => ['HTTP_HOST' => 'localhost']
+        ]);
+        Router::pushRequest($request);
+
+        $result = Router::url([
+            'controller' => 'images',
+            'action' => 'index',
+            '_ssl' => true,
+            '_full' => true
+        ]);
+        $this->assertEquals('https://app.localhost/images/index', $result);
+
+        $result = Router::url([
+            'controller' => 'images',
+            'action' => 'index',
+            '_ssl' => false,
+            '_full' => true,
+        ]);
+        $this->assertEquals('http://app.localhost/images/index', $result);
+
+        $result = Router::url([
+            'controller' => 'images',
+            'action' => 'index',
+            '_full' => false,
+            '_ssl' => false
+        ]);
+        $this->assertEquals('http://localhost/images/index', $result);
+    }
+
+    /**
      * Test ssl option when the current request is ssl.
      *
      * @return void