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
test for wp_delete_file_from_directory and update to Function to stop… - #5603
The changes in this pull request can previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.
Some things to be aware of
All changes will be lost when closing a tab with a Playground instance.
All changes will be lost when refreshing the page.
A fresh instance is created each time the link below is clicked.
Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.
Extra blank line inside this guard clause deviates from the surrounding style (and is the only instance of this pattern in functions.php), which may fail whitespace/style checks.
Test class name casing is inconsistent with other tests/phpunit/tests/functions/* tests (typically Tests_Functions_*). This makes the suite harder to navigate/search consistently.
class Tests_functions_wpDeleteFileFromDirectory extends WP_UnitTestCase {
The reason will be displayed to describe this comment to others. Learn more.
The source guard rejects every registered stream wrapper except file:, although the existing function passes supported wrappers through its containment check and deletion. Please preserve that contract, or establish the intended compatibility change separately. The php:// plus local-path example does not justify rejecting working custom filesystem wrappers. Please also give the temporary file cleanup that runs after assertion failures.
The reason will be displayed to describe this comment to others. Learn more.
The Copilot review looks correct to me. Aside from that, I think it would be good to have a test that confirms a file can't be deleted outside the folder by using path traversal.
Preserve deletion support for registered stream wrappers
src/wp-includes/functions.php:7887
This guard rejects registered non-file wrappers that implement unlink(), so a contained path such as custom://bucket/uploads/image.jpg now returns false without attempting deletion. Because wp_delete_attachment_files() uses this helper, attachment files stored through these wrappers can be left behind. Preserve support for deletable wrappers by letting the existing directory check and wp_delete_file() determine success.
The reason will be displayed to describe this comment to others. Learn more.
The current head still rejects registered filesystem wrappers that could delete files before this change. In a temporary-file check using the same registered wrapper and call on both revisions, the base returned true and deleted the file. This head returned false and left it in place. Please preserve working wrappers and keep any intentional change to that filesystem contract in a separate proposal.
The revised php://temp test uses the same URL as both file and directory. The existing directory-prefix check already rejects that input, so it does not demonstrate a need for the new guard. Please also use unique temporary files and clean them up even when an assertion fails. The existing path traversal review remains open.
AI review · gpt-6.2-astra
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.
… stream URL failing
Trac ticket: https://core.trac.wordpress.org/ticket/59781