Attempt to fix ENAMETOOLONG error by filtering and deduping open_basedir - #4432
Open
fredrikekelund wants to merge 4 commits into
Open
Attempt to fix ENAMETOOLONG error by filtering and deduping open_basedir#4432fredrikekelund wants to merge 4 commits into
ENAMETOOLONG error by filtering and deduping open_basedir#4432fredrikekelund wants to merge 4 commits into
Conversation
Collaborator
📊 Performance Test ResultsComparing 56b9959 vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related issues
How AI was used in this PR
I used Claude to iterate in relatively small chunks towards a result I liked. I used Codex to review the result.
Proposed Changes
In #4173, @Tropicalista reported an issue where native PHP sites with "site directory" file access would fail to start and report an
ENAMETOOLONGerror.ENAMETOOLONGerrors indicate that the CLI command was too long for the OS to handle (there is such a limit). We don't know what exactly made the command so long, but our best theory is that it's theopen_basedirdirective, which is passed as a CLI option. It could have happened if there was a pnpm-stylenode_modulesdirectory anywhere in the site directory, for example (since this means there can be hundreds of symlink paths in theopen_basedirdirective).This PR fixes the problem by applying the following changes:
node_modules,.git, and.DS_Storepaths infindSymlinksInDir(). Previously, we only ignored those paths when watching for new symlinks. If a pnpm-stylenode_modulesdir is the source of the problem, then this is the key fix.open_basedirlist contains/lorem/ipsumand/lorem/ipsum/dolor,/lorem/ipsum/doloris now dropped before passing the list to PHP (because it is redundant). This change also ensures that newly added symlinks pointing to an already allowed directory don't trigger a process restart.The next logical step would be to put the
open_basedirdirective in a site-specificphp.inifile. I'll leave that for another PR, though.Testing Instructions
cdintowp-content/pluginsfor that siteln -s PATH_TO_DOWNLOADED_EXTRACTED_PLUGIN_DIRPluginsin the sidebarThis routine ensures that basic symlink watcher functionality and
open_basedircompilation still work as expected. It does not test theENAMETOOLONGerror specifically, as we don't know exactly how to reproduce that.Pre-merge Checklist