You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(symlink-cleaner): detect symlinks via resolved path instead of stat mode - #288
SymlinkCleaner::isSymlink() checked the S_IFLNK bit of FileDriver::stat(). stat() follows symlinks and returns the mode of the link target, so symlinks in {theme}/web/css/ were never detected and never removed in developer mode. The existing unit tests mocked stat() with a symlink mode, which hid the bug.
Fix
Detect symlinks via FileDriver::getRealPath(): an entry whose real path differs from <real css dir>/<name> is a symlink. This also works when the theme itself lives behind a symlinked directory.
Broken symlinks (real path cannot be resolved) are removed as well.
Tests now mock getRealPath() and add a test against the real filesystem (fails on the old implementation).
…at mode
SymlinkCleaner checked the S_IFLNK bit of FileDriver::stat(), but stat()
follows links and reports the target's mode, so symlinks in web/css were
never detected or removed. Compare the entry's real path with its expected
location in the resolved css directory instead; unresolvable (broken)
links are removed as well.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The path comparison normalizes valid backslashes in POSIX filenames, causing cleanSymlinks() to delete regular files incorrectly.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Preserve literal POSIX filenames when cleaning symlinks
src/Service/SymlinkCleaner.php:112
On POSIX filesystems, a backslash is a valid filename character, but getBasename() converts it into a directory separator. A regular file named custom\styles.css therefore resolves to <css>/custom\styles.css while this comparison expects <css>/styles.css, so cleanSymlinks() deletes the regular file. Preserve the entry's literal filename when constructing its expected path rather than using the separator-normalising display helper.
The Static Analysis workflow analyses the tests inside the Magento install,
which pins PHPUnit 10.5 where getStubBuilder() does not exist. The tests run
with the PHPUnit 12 required by composer.json, so ignore only this message.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
A critical Windows path-separator mismatch causes regular CSS files to be misidentified as symlinks and deleted during cleanup.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Normalize Windows path separators before symlink comparison
src/Service/SymlinkCleaner.php:112
On Windows, a regular file resolves to C:\theme\web\css\styles.css, but this expression builds C:\theme\web\css/styles.css. The separator mismatch makes isSymlink() return true for regular files, so cleanup deletes the theme's actual CSS files. Normalise separators in both resolved paths before comparing them, and cover a backslash-separated regular-file path in the tests.
Take main's fix (#290) for getStubBuilder and the overlong line, and drop the
now redundant phpstan.neon ignore.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The symlink comparison can misclassify and delete regular POSIX files whose names contain backslashes, so entry names must be extracted using platform-aware separators.
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
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.
Problem
SymlinkCleaner::isSymlink()checked theS_IFLNKbit ofFileDriver::stat().stat()follows symlinks and returns the mode of the link target, so symlinks in{theme}/web/css/were never detected and never removed in developer mode. The existing unit tests mockedstat()with a symlink mode, which hid the bug.Fix
FileDriver::getRealPath(): an entry whose real path differs from<real css dir>/<name>is a symlink. This also works when the theme itself lives behind a symlinked directory.getRealPath()and add a test against the real filesystem (fails on the old implementation).Verification
phpunit tests/Unit/Service/SymlinkCleanerTest.php: 10 tests passphpcsandphpstanclean for the changed filesThe changelog entry is generated by Release Please from the title.