Browse Source

Merge branch 'master' into 3.next

Mark Story 9 years ago
parent
commit
7ffb4012ac

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

@@ -455,10 +455,7 @@ class RequestHandlerComponent extends Component
             return false;
         }
 
-        list($contentType) = explode(';', $request->env('CONTENT_TYPE'));
-        if ($contentType === '') {
-            list($contentType) = explode(';', $request->header('CONTENT_TYPE'));
-        }
+        list($contentType) = explode(';', $request->contentType());
         $response = $this->response;
         if ($type === null) {
             return $response->mapType($contentType);

+ 3 - 7
src/Error/Debugger.php

@@ -317,17 +317,13 @@ class Debugger
      */
     public static function trimPath($path)
     {
-        if (!defined('CAKE_CORE_INCLUDE_PATH') || !defined('APP')) {
-            return $path;
-        }
-
-        if (strpos($path, APP) === 0) {
+        if (defined('APP') && strpos($path, APP) === 0) {
             return str_replace(APP, 'APP/', $path);
         }
-        if (strpos($path, CAKE_CORE_INCLUDE_PATH) === 0) {
+        if (defined('CAKE_CORE_INCLUDE_PATH') && strpos($path, CAKE_CORE_INCLUDE_PATH) === 0) {
             return str_replace(CAKE_CORE_INCLUDE_PATH, 'CORE', $path);
         }
-        if (strpos($path, ROOT) === 0) {
+        if (defined('ROOT') && strpos($path, ROOT) === 0) {
             return str_replace(ROOT, 'ROOT', $path);
         }
 

+ 1 - 0
src/Filesystem/Folder.php

@@ -398,6 +398,7 @@ class Folder
      *
      * @param string $path The path to check.
      * @return bool
+     * @deprecated 3.2.12 This method will be removed in 4.0.0. Use inPath() instead.
      */
     public function inCakePath($path = '')
     {

+ 1 - 1
src/I18n/MessagesFileLoader.php

@@ -159,7 +159,7 @@ class MessagesFileLoader
         $searchPaths = [];
 
         $localePaths = App::path('Locale');
-        if (empty($localePaths)) {
+        if (empty($localePaths) && defined('APP')) {
             $localePaths[] = APP . 'Locale' . DIRECTORY_SEPARATOR;
         }
         foreach ($localePaths as $path) {

+ 4 - 1
src/Network/Request.php

@@ -898,7 +898,10 @@ class Request implements ArrayAccess
      */
     public function header($name)
     {
-        $name = 'HTTP_' . str_replace('-', '_', $name);
+        $name = str_replace('-', '_', $name);
+        if (!in_array(strtoupper($name), ['CONTENT_LENGTH', 'CONTENT_TYPE'])) {
+            $name = 'HTTP_' . $name;
+        }
         return $this->env($name);
     }
 

+ 1 - 1
src/Network/Response.php

@@ -328,7 +328,7 @@ class Response
      * Content type to send. This can be an 'extension' that will be transformed using the $_mimetypes array
      * or a complete mime-type
      *
-     * @var int
+     * @var string
      */
     protected $_contentType = 'text/html';
 

+ 4 - 1
src/basics.php

@@ -52,7 +52,10 @@ if (!function_exists('debug')) {
         $lineInfo = '';
         if ($showFrom) {
             $trace = Debugger::trace(['start' => 1, 'depth' => 2, 'format' => 'array']);
-            $search = [ROOT];
+            $search = [];
+            if (defined('ROOT')) {
+                $search = [ROOT];
+            }
             if (defined('CAKE_CORE_INCLUDE_PATH')) {
                 array_unshift($search, CAKE_CORE_INCLUDE_PATH);
             }

+ 1 - 2
tests/TestCase/Controller/Component/RequestHandlerComponentTest.php

@@ -773,8 +773,7 @@ class RequestHandlerComponentTest extends TestCase
         $this->assertEquals('json', $this->RequestHandler->requestedWith());
 
         $this->request->env('REQUEST_METHOD', 'POST');
-        $this->request->env('CONTENT_TYPE', '');
-        $this->request->env('HTTP_CONTENT_TYPE', 'application/json');
+        $this->request->env('CONTENT_TYPE', 'application/json');
 
         $result = $this->RequestHandler->requestedWith(['json', 'xml']);
         $this->assertEquals('json', $result);

+ 7 - 1
tests/TestCase/Network/RequestTest.php

@@ -1055,11 +1055,17 @@ class RequestTest extends TestCase
     {
         $request = new Request(['environment' => [
             'HTTP_HOST' => 'localhost',
-            'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-ca) AppleWebKit/534.8+ (KHTML, like Gecko) Version/5.0 Safari/533.16'
+            'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-ca) AppleWebKit/534.8+ (KHTML, like Gecko) Version/5.0 Safari/533.16',
+            'CONTENT_TYPE' => 'application/json',
+            'CONTENT_LENGTH' => 1337,
+            'HTTP_CONTENT_MD5' => 'abc123'
         ]]);
 
         $this->assertEquals($request->env('HTTP_HOST'), $request->header('host'));
         $this->assertEquals($request->env('HTTP_USER_AGENT'), $request->header('User-Agent'));
+        $this->assertEquals($request->env('CONTENT_LENGTH'), $request->header('content-length'));
+        $this->assertEquals($request->env('CONTENT_TYPE'), $request->header('content-type'));
+        $this->assertEquals($request->env('HTTP_CONTENT_MD5'), $request->header('content-md5'));
     }
 
     /**

+ 1 - 1
tests/TestCase/Utility/TextTest.php

@@ -1607,7 +1607,7 @@ TEXT;
                 'Foo Bar: Not just for breakfast any-more'
             ],
             [
-                'A æ Übérmensch på høyeste nivå! И я люблю PHP! есть. fi ¦', null,
+                'A æ Übérmensch på høyeste nivå! И я люблю PHP! ест. fi ¦', null,
                 'A ae Ubermensch pa hoyeste niva! I a lublu PHP! est. fi '
             ],
             [