Skip to content

fix(core): download WordPress core without truncated file names - #241

Merged
mrrobot47 merged 4 commits into
EasyEngine:developfrom
mrrobot47:fix/wp-core-download-truncation
Sep 29, 2026
Merged

mrrobot47 merged 4 commits into
EasyEngine:developfrom
mrrobot47:fix/wp-core-download-truncation

Conversation

@mrrobot47

@mrrobot47 mrrobot47 commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Depends on EasyEngine/site-command#504, which is merged: this PR calls the get_wp_core_download_command() helper added there, so both need to be released and pinned together.

Problem

WordPress 7.x .tar.gz packages store paths longer than 100 bytes in PAX headers. WP-CLI 2.12 and older extracts them with PHP's PharData, which ignores those headers and truncates the names (wp-cli/wp-cli#6320, php/php-src#19311). On every new en_US WordPress 7.x site, 25 files under wp-includes/php-ai-client/ get truncated names and some are lost, so WordPress fatals as soon as the AI client is used, and wp core verify-checksums fails. Localized packages aren't affected.

Sites that were already created this way stay broken. A later core update restores the missing files but leaves the 21 truncated leftovers behind.

Fix

  • ee site create --type=wp now downloads core through site-command's shared download helper: wp core download --no-extract, extraction with tar or unzip, then a wp core verify-checksums gate.
  • The retry loop's EE::error() was unreachable, so a failed download went unnoticed and site creation carried on. Failures now throw, which runs the usual clean-up, and report WP-CLI's error without repeating its "Error: " prefix. Errors that retrying can't fix (unknown version or locale, checksum failures) aren't retried.
  • When WordPress.org's checksums can't be fetched, the create still succeeds and now shows the "Could not verify WordPress core checksums" warning instead of logging it only in debug mode.
  • Without the site-command helper, the create fails with a clear message and the usual clean-up instead of an uncaught \Error.
  • --version and --skip-content are no longer concatenated into the shell command unescaped.
  • A new migration repairs existing WordPress 7.x sites: for each WordPress site with wp-includes/php-ai-client/, it runs wp core verify-checksums in the php container, extracts that directory from the site's version and locale package into a temp dir and only then copies it in, deletes the truncated leftovers and verifies again. A corrupt package from WP-CLI's cache is replaced by a fresh md5-checked download, so it can't leave half-written files.
  • Only extra files with the truncated-name signature are deleted, so other files in php-ai-client/ are left alone. A site is reported as repaired only when the final check passes; when the checksums can't be fetched, the migration says the repair is unverified.
  • The repair covers only the php-ai-client files. The 14 truncated default-theme files that en_US 6.7.2+ sites keep under wp-content aren't covered by verify-checksums, so they aren't repaired.
  • The migration uses no database, never loads WordPress and can be re-run. Disabled sites, stopped sites, sites that can't be checked, sites that fail to repair and a site-command without the helper get a warning with the manual check command; the migration itself never fails.

Testing

  • New sites (en_US, nl_NL, --skip-content, 6.9) on PHP 7.4 to 8.5 pass wp core verify-checksums with all 146 php-ai-client files in place.
  • An unknown --version or --locale fails after one attempt with WP-CLI's error and leaves nothing behind. So does a create with a site-command that lacks the helper.
  • With api.wordpress.org unreachable, a create succeeds and shows the checksum warning.
  • The migration repaired broken single, multisite and customised sites and a site with a corrupt cached package, left healthy 6.9 and nl_NL sites and customised files untouched, and changed nothing on a re-run. It warned without failing for a disabled site, a stopped php container, unreachable WordPress.org and a check that failed after the repair.

`wp core download` with WP-CLI <= 2.12 extracts the .tar.gz with PharData, which truncates paths over 100 bytes in the PAX headers of WordPress >= 6.7.2 en_US packages (wp-cli/wp-cli#6320). New 7.x sites were missing wp-includes/php-ai-client classes. Use site-command's get_wp_core_download_command(), which extracts with tar/unzip and checks the result with `wp core verify-checksums`.

Also fix the retry loop: its EE::error() was unreachable, so a failed download went unnoticed and site creation carried on. Failures now throw, which runs the usual clean-up, and report WP-CLI's error. Errors that retrying can't fix (unknown version or locale, checksum failures) aren't retried. --version and --skip-content are no longer concatenated into the shell command unescaped.

Requires the site-command release that adds get_wp_core_download_command().
… sites

Sites created with the old `wp core download` on WordPress 7.x have 25 missing and 21 truncated files under wp-includes/php-ai-client/. A later core update restores the missing ones but leaves the truncated leftovers.

For each enabled WordPress site with that directory, run `wp core verify-checksums` in the php container and match its warnings under wp-includes/php-ai-client/ (the exit code is 0 in the healed state). Restore only that directory from the md5-checked package of the site's version and locale, delete the leftovers (90-character, non-.php names flagged by verify-checksums) and verify again. No database, WordPress is never loaded, and it can be re-run. Sites that are stopped, can't be checked or fail to repair get a warning with the manual check; the migration itself never fails.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The migration can be permanently skipped when its dependency is unavailable and can report success after an unsuccessful final verification.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Updates WordPress core downloads and repairs installations affected by truncated archive paths.

Changes:

  • Uses the shared verified download/extraction helper with retry handling.
  • Adds an idempotent migration to repair affected WordPress installations.
File Description
src/​WordPress.php Replaces direct WP-CLI downloads with the shared helper.
migrations/​container/​20260924160000_site-type-wp_repair_truncated_core_files.php Detects and repairs truncated core files.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread migrations/container/20260924160000_site-type-wp_repair_truncated_core_files.php Outdated
Comment thread migrations/container/20260924160000_site-type-wp_repair_truncated_core_files.php Outdated
…download helper

- When WordPress.org's checksums can't be fetched, the download still succeeds, but its "Could not verify WordPress core checksums" warning now reaches the user instead of only the debug log.
- A site-command without `get_wp_core_download_command()` now fails the create with a clear message and the usual clean-up, instead of an `\Error` that `create_site()` doesn't catch.
- The failure reason no longer repeats WP-CLI's "Error: " prefix.
- The retry comment now says why force is needed on every path.
… verified repairs

- The package is extracted into a temp dir and only then copied into wp-includes/php-ai-client/. A corrupt package from WP-CLI's cache, which isn't md5-checked again, used to leave half-written files in a working site; now a fresh copy is fetched once instead.
- Only extra files with the truncated-name signature count as leftovers, so other files in php-ai-client/ no longer cause a false "Could not repair" warning.
- The final check fails on checksum mismatches under php-ai-client/ and reports "unverified" when the checksums can't be fetched, instead of claiming the repair was verified.
- Disabled sites and a site-command without the helper now get a warning with the manual check command instead of being skipped silently, since the migration is recorded either way.
- "unverified" reasons show WP-CLI's error line, and the docblock says which packages and files are covered.
@mrrobot47
mrrobot47 merged commit c078ae7 into EasyEngine:develop Sep 29, 2026
1 of 5 checks passed
@mrrobot47
mrrobot47 deleted the fix/wp-core-download-truncation branch September 29, 2026 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants