Fix is_readable() to test readability, not writability - #41
Merged
Conversation
VirtualFilesystemDirect::is_readable() delegated to is_writeable(), so a read-only entry (0444) was wrongly reported as not readable. Because dirlist() gates on is_readable(), listing a read-only directory returned false — a false negative for the exact permission scenario this filesystem mock exists to reproduce. Use is_readable() for the predicate, and add regression coverage: - isReadable: 0444 asserts true - isWritable: 0444 asserts false (guards the inverse regression) - dirlist: read-only directory still returns its listing Fixes #34 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
VirtualFilesystemDirect::is_readable()delegated tois_writeable(), so it returned an entry's writability instead of its readability. A read-only entry (0444) is readable but not writable, and was wrongly reported as "not readable".This is not cosmetic:
dirlist()gates onis_readable(), so listing a read-only directory returnedfalse— a false negative for exactly the permission scenario this filesystem mock exists to reproduce.Change
Regression coverage
isReadable.php:0444assertstrueisWritable.php:0444assertsfalse(guards against the inverse regression)dirlist.php: a read-only directory still returns its listing, notfalseThe pre-existing unit tests only covered
0777(→ true) and000(→ false), both of which passed under the buggy delegation, which is why this went unnoticed.Validation
Ran the full suite in Docker via
wp-env(WordPress test site, PHP 8.3.33, PHPUnit 9.6.35):Both new read-only cases were confirmed to execute (not silently skipped).
Fixes #34
🤖 Generated with Claude Code