@@ -53,7 +53,6 @@ abstract class Kernel implements KernelInterface, TerminableInterface
53
53
protected $ bundleMap ;
54
54
protected $ container ;
55
55
protected $ rootDir ;
56
- protected $ realRootDir ;
57
56
protected $ environment ;
58
57
protected $ debug ;
59
58
protected $ booted ;
@@ -732,17 +731,24 @@ private function removeAbsolutePathsFromContainer($content)
732
731
return $ content ;
733
732
}
734
733
735
- $ rootDir = $ this ->getRealRootDir ();
736
- if (!$ rootDir ) {
737
- return $
10000
content ;
734
+ // find the "real" root dir (by finding the composer.json file)
735
+ $ rootDir = $ this ->getRootDir ();
736
+ $ previous = $ rootDir ;
737
+ while (!file_exists ($ rootDir .'/composer.json ' )) {
738
+ if ($ previous === $ rootDir = realpath ($ rootDir .'/.. ' )) {
739
+ // unable to detect the project root, give up
740
+ return $ content ;
741
+ }
742
+
743
+ $ previous = $ rootDir ;
738
744
}
739
745
740
746
$ rootDir = rtrim ($ rootDir , '/ ' );
741
747
$ cacheDir = $ this ->getCacheDir ();
742
748
$ filesystem = new Filesystem ();
743
749
744
- return preg_replace_callback ("{'([^']*? )( " .preg_quote ($ rootDir )."[^']*)'} " , function ($ match ) use ($ filesystem , $ cacheDir ) {
745
- $ prefix = ! empty ($ match [1 ]) ? "' $ match [1 ]'.__DIR__ " : "__DIR__ " ;
750
+ return preg_replace_callback ("{'([^']*)( " .preg_quote ($ rootDir )."[^']*)'} " , function ($ match ) use ($ filesystem , $ cacheDir ) {
751
+ $ prefix = isset ($ match [1 ]) && $ match [ 1 ] ? "' $ match [1 ]'.__DIR__ " : "__DIR__ " ;
746
752
747
753
if ('. ' === $ relativePath = rtrim ($ filesystem ->makePathRelative ($ match [2 ], $ cacheDir ), '/ ' )) {
748
754
return $ prefix ;
@@ -752,33 +758,6 @@ private function removeAbsolutePathsFromContainer($content)
752
758
}, $ content );
753
759
}
754
760
755
- /**
756
- * Find the "real" root dir (by finding the composer.json file)
757
- *
758
- * @return null|string
759
- */
760
- private function getRealRootDir ()
761
- {
762
- if (null !== $ this ->realRootDir ) {
763
- return $ this ->realRootDir ;
764
- }
765
-
766
- $ rootDir = $ this ->getRootDir ();
767
- $ previous = $ rootDir ;
768
- while (!file_exists ($ rootDir .'/composer.json ' )) {
769
- if ($ previous === $ rootDir = realpath ($ rootDir .'/.. ' )) {
770
- // unable to detect the project root, give up
771
- return $ this ->realRootDir = false ;
772
- }
773
-
774
- $ previous = $ rootDir ;
775
- }
776
-
777
- $ this ->realRootDir = $ rootDir ;
778
-
779
- return $ this ->realRootDir ;
780
- }
781
-
782
761
/**
783
762
* Returns a loader for the container.
784
763
*
0 commit comments