[9.x] Fix PHP warnings when rendering long blade string #41956
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
\Illuminate\View\Component::resolveViewchecks the string for being a fileby calling
\Illuminate\Filesystem\Filesystem::existsmethod, which is a pure standardfile_existsfunction.PHP has a hard limit on path length as defined by the constant PHP_MAXPATHLEN which depends on the operating system (Windows 260 characters, Unix: as specified in the c-runtime - on Linux this is
PATH_MAXin limits.h being 4096).PHP detects the program is trying to check plain file existence and calls
php_check_open_basedirIf the PHP configuration has no
open_basedirvalue, then another methodvirtual_file_exwill be called:But
virtual_file_exdoesn't throw warnings, just returnsfalse.If
open_basediris configured,php_check_open_basedir_exis called, it cares aboutopen_basedirand throws a warning, otherwisefile_existsjust returns false. The program behavior depends ofopen_basedirsetting.Although it's OK in the PHP design paradigm, users meet problems from time to time having this warning, see #32254 #41745 livewire/livewire#918
This PR adds PHP_MAXPATHLEN check before calling
file_exists.Although I can add a test case for different open_basedir states, it will affect other tests running in parallel, and considering the issue is rare, I don't think there is a sense to make a custom php.ini environment for the case.