Skip to content
Draft
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
41efc3a
Initial plan
Copilot Nov 7, 2025
baee2fa
Add support for cleaning up old files using WordPress $_old_files list
Copilot Nov 7, 2025
37cfece
Enhance cleanup to use $_old_files even when checksums are available
Copilot Nov 7, 2025
4760835
Update tests and documentation to reflect new cleanup behavior
Copilot Nov 7, 2025
5a094a0
Address code review feedback - improve error handling and reduce dupl…
Copilot Nov 7, 2025
bf5a413
Remove @ error suppression operators per code review feedback
Copilot Nov 7, 2025
fe5a714
Use directory_separator
swissspidy Nov 7, 2025
12fd04b
Path validation
swissspidy Nov 7, 2025
d5ffb6d
Adjust message
swissspidy Nov 7, 2025
96fcab2
Refactor to reduce code duplication and add symlink handling
Copilot Nov 7, 2025
038d662
Add path validation and improve security checks
Copilot Nov 7, 2025
92f2049
Fix path validation logic for better security
Copilot Nov 7, 2025
0d1bfb3
Optimize path validation by caching ABSPATH realpath
Copilot Nov 7, 2025
6b30e73
Clean up code style - remove trailing whitespace and simplify logic
Copilot Nov 7, 2025
831e197
Lint & test fixes
swissspidy Nov 10, 2025
1a5cb90
Merge branch 'main' into copilot/add-delete-old-core-files
swissspidy Dec 7, 2025
0064498
Add comprehensive test coverage for old files cleanup functionality
Copilot Dec 7, 2025
253a873
Apply suggestions from code review
swissspidy Dec 7, 2025
40c7fc5
Remove custom old_files test and improve checksums unavailable test w…
Copilot Dec 8, 2025
8ab689b
Gherkin lint fix
swissspidy Dec 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion features/core-download.feature
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ Feature: Download WordPress
"""
Failed to find WordPress version
"""
And STDERR should contain:
And STDERR should not contain:
"""
Warning: Checksums not available for WordPress nightly/en_US. Please cleanup files manually.
"""
Expand Down
143 changes: 143 additions & 0 deletions features/core-update.feature
Original file line number Diff line number Diff line change
Expand Up @@ -384,3 +384,146 @@ Feature: Update WordPress core
"""
Success:
"""

@require-php-7.2
Scenario: Old files from $_old_files are cleaned up when upgrading
Given a WP install

When I run `wp core download --version=6.8 --force`
Then STDOUT should contain:
"""
Success: WordPress downloaded.
"""

# Create files that should be removed according to 6.9 old_files list
Given a wp-includes/blocks/post-author/editor.css file:
"""
/* Old CSS file */
"""
And a wp-includes/blocks/post-author/editor.min.css file:
"""
/* Old minified CSS */
"""
And a wp-includes/blocks/post-author/editor-rtl.css file:
"""
/* Old RTL CSS */
"""
And a wp-includes/blocks/post-author/editor-rtl.min.css file:
"""
/* Old RTL minified CSS */
"""
And a wp-includes/SimplePie/src/Core.php file:
"""
<?php
// Old SimplePie Core file
"""
And a wp-includes/SimplePie/src/Decode directory

When I run `wp core update --version=6.9 --force`
Then STDOUT should contain:
"""
Success: WordPress updated successfully.
"""
And the wp-includes/blocks/post-author/editor.css file should not exist
And the wp-includes/blocks/post-author/editor.min.css file should not exist
And the wp-includes/blocks/post-author/editor-rtl.css file should not exist
And the wp-includes/blocks/post-author/editor-rtl.min.css file should not exist
And the wp-includes/SimplePie/src/Core.php file should not exist
And the wp-includes/SimplePie/src/Decode directory should not exist

@require-php-7.2
Scenario: Custom old_files list is used for cleanup
Given a WP install

When I run `wp core download --version=6.8 --force`
Then STDOUT should contain:
"""
Success: WordPress downloaded.
"""

# Create test files that we'll add to custom old_files list
Given a wp-includes/test-old-file-1.php file:
"""
<?php
// Test old file 1
"""
And a wp-includes/test-old-file-2.php file:
"""
<?php
// Test old file 2
"""
And a wp-includes/test-old-dir directory
And a wp-includes/test-old-dir/test-file.php file:
"""
<?php
// Test file in old directory
"""

# Modify update-core.php to include our test files in old_files list
And a wp-admin/includes/update-core-custom.php file:
"""
<?php
global $_old_files;
require_once ABSPATH . 'wp-admin/includes/update-core.php';
$_old_files[] = 'wp-includes/test-old-file-1.php';
$_old_files[] = 'wp-includes/test-old-file-2.php';
$_old_files[] = 'wp-includes/test-old-dir';
"""

# Backup original and replace with custom version
When I run `mv wp-admin/includes/update-core.php wp-admin/includes/update-core-backup.php`
And I run `mv wp-admin/includes/update-core-custom.php wp-admin/includes/update-core.php`

When I run `wp core update --version=6.9 --force`
Then STDOUT should contain:
"""
Success: WordPress updated successfully.
"""

# Restore original update-core.php
When I run `mv wp-admin/includes/update-core-backup.php wp-admin/includes/update-core.php`

# Verify custom old files were removed
Then the wp-includes/test-old-file-1.php file should not exist
And the wp-includes/test-old-file-2.php file should not exist
And the wp-includes/test-old-dir directory should not exist

@require-php-7.2
Scenario: Old files cleanup works when checksums unavailable
Given a WP install

When I run `wp core download --version=6.8 --force`
Then STDOUT should contain:
"""
Success: WordPress downloaded.
"""

# Create files that should be removed
Given a wp-includes/test-cleanup-file.php file:
"""
<?php
// Test cleanup file
"""

# Modify update-core.php to include our test file
And a wp-admin/includes/update-core-custom.php file:
"""
<?php
global $_old_files;
require_once ABSPATH . 'wp-admin/includes/update-core.php';
$_old_files[] = 'wp-includes/test-cleanup-file.php';
"""

When I run `mv wp-admin/includes/update-core.php wp-admin/includes/update-core-backup.php`
And I run `mv wp-admin/includes/update-core-custom.php wp-admin/includes/update-core.php`

# Update to a version where checksums might not be available
When I try `wp core update --version=nightly --force`
Then STDOUT should contain:
"""
Cleaning up files...
"""

When I run `mv wp-admin/includes/update-core-backup.php wp-admin/includes/update-core.php`

Then the wp-includes/test-cleanup-file.php file should not exist
Loading
Loading