Browse Source

Merge pull request #9081 from cakephp/issue-9074

Make constants optional.
José Lorenzo Rodríguez 9 years ago
parent
commit
3cafdd18fd
4 changed files with 9 additions and 9 deletions
  1. 3 7
      src/Error/Debugger.php
  2. 1 0
      src/Filesystem/Folder.php
  3. 1 1
      src/I18n/MessagesFileLoader.php
  4. 4 1
      src/basics.php

+ 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/basics.php

@@ -50,7 +50,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);
             }