Add automatic cleanup of old core files using WordPress $_old_files list#299
Merged
swissspidy merged 43 commits intomainfrom Mar 16, 2026
Merged
Add automatic cleanup of old core files using WordPress $_old_files list#299swissspidy merged 43 commits intomainfrom
swissspidy merged 43 commits intomainfrom
Conversation
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
…ication Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add command to delete old core files after update
Add automatic cleanup of old core files using WordPress $_old_files list
Nov 7, 2025
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Contributor
|
we also need to check that this will not cause a regression of #196 |
This comment was marked as resolved.
This comment was marked as resolved.
…realpath calls Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
… into a single pass Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot stopped work on behalf of
swissspidy due to an error
March 12, 2026 07:58
swissspidy
reviewed
Mar 12, 2026
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
swissspidy
reviewed
Mar 12, 2026
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.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.
Feature: Add support for deleting old core files using WordPress $_old_files list
Problem
Currently, when checksums for the target WordPress version and locale aren't available, WP-CLI warns users to manually clean up old files. This is inconvenient and error-prone.
Solution
This PR implements automatic cleanup using WordPress core's
$_old_filesglobal array fromwp-admin/includes/update-core.php.Cleanup Order
Old files from WordPress core's
$_old_fileslist are always cleaned up first, before fetching and comparing checksums. If checksums are available, the checksum-based diff cleanup follows.Changes Made
cleanup_extra_files()-cleanup_old_files()now runs unconditionally at the startcleanup_old_files()- runs unconditionallycleanup_old_files_not_in_checksums()- now redundantget_old_files_list()- centralizes access to$_old_filesarrayremove_old_files_from_list()- single-pass helper with early exit and path validationremove_directory()- usesRecursiveIteratorIterator/RecursiveDirectoryIteratorwithCHILD_FIRSTorderingNo files found that need cleaning up→No old files were removed.No old files were removed.and the warning about checksums being unavailableTesting
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.