diff --git a/src/Illuminate/View/Component.php b/src/Illuminate/View/Component.php index dcbe764c506b..6768fdcbb1c2 100644 --- a/src/Illuminate/View/Component.php +++ b/src/Illuminate/View/Component.php @@ -170,7 +170,7 @@ protected function extractBladeViewFromString($contents) return static::$bladeViewCache[$key]; } - if (strlen($contents) <= PHP_MAXPATHLEN && $this->factory()->exists($contents)) { + if ($this->factory()->exists($contents)) { return static::$bladeViewCache[$key] = $contents; } diff --git a/src/Illuminate/View/FileViewFinder.php b/src/Illuminate/View/FileViewFinder.php index 107bf7c36bdc..4b2f32679307 100755 --- a/src/Illuminate/View/FileViewFinder.php +++ b/src/Illuminate/View/FileViewFinder.php @@ -128,7 +128,9 @@ protected function findInPaths($name, $paths) { foreach ((array) $paths as $path) { foreach ($this->getPossibleViewFiles($name) as $file) { - if ($this->files->exists($viewPath = $path.'/'.$file)) { + $viewPath = $path.'/'.$file; + + if (strlen($viewPath) <= PHP_MAXPATHLEN && $this->files->exists($viewPath)) { return $viewPath; } } diff --git a/tests/Integration/View/BladeTest.php b/tests/Integration/View/BladeTest.php index 61dc2cb32814..cff73e6a7bca 100644 --- a/tests/Integration/View/BladeTest.php +++ b/tests/Integration/View/BladeTest.php @@ -7,6 +7,7 @@ use Illuminate\Support\Facades\View; use Illuminate\View\Component; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\SplFileInfo; @@ -26,6 +27,29 @@ public function test_rendering_blade_long_maxpathlen_string() $this->assertSame($longString.'a', $result); } + #[RunInSeparateProcess] + public function test_rendering_blade_long_maxpathlen_string_with_exact_length() + { + // The PHP_MAXPATHLEN restriction is only active, if + // open_basedir is set and active. Otherwise, the check + // for the PHP_MAXPATHLEN is not active. + if (ini_get('open_basedir') === '') { + $openBaseDir = windows_os() ? explode('\\', __DIR__)[0].'\\'.';'.sys_get_temp_dir() : '/'; + $iniSet = ini_set( + 'open_basedir', + $openBaseDir + ); + + $this->assertNotFalse($iniSet, 'Could not set config for open_basedir.'); + } + + $longString = str_repeat('x', PHP_MAXPATHLEN); + + $result = Blade::render($longString); + + $this->assertSame($longString, $result); + } + public function test_rendering_blade_component_instance() { $component = new HelloComponent('Taylor');