[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::resolveView
checks the string for being a fileby calling
\Illuminate\Filesystem\Filesystem::exists
method, which is a pure standardfile_exists
function.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_MAX
in limits.h being 4096).PHP detects the program is trying to check plain file existence and calls
php_check_open_basedir
If the PHP configuration has no
open_basedir
value, then another methodvirtual_file_ex
will be called:But
virtual_file_ex
doesn't throw warnings, just returnsfalse
.If
open_basedir
is configured,php_check_open_basedir_ex
is called, it cares aboutopen_basedir
and throws a warning, otherwisefile_exists
just returns false. The program behavior depends ofopen_basedir
setting.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.