Skip to content

Upgrade/Install: Clean up working directory after installation failure#12676

Draft
ArkaPrabhaChowdhury wants to merge 5 commits into
WordPress:trunkfrom
ArkaPrabhaChowdhury:trac-44710-upgrader-cleanup
Draft

Upgrade/Install: Clean up working directory after installation failure#12676
ArkaPrabhaChowdhury wants to merge 5 commits into
WordPress:trunkfrom
ArkaPrabhaChowdhury:trac-44710-upgrader-cleanup

Conversation

@ArkaPrabhaChowdhury

Copy link
Copy Markdown

Trac ticket: https://core.trac.wordpress.org/ticket/44710

Ensures extracted upgrade working directories are removed when package installation fails and clear_working is enabled. Adds focused regression coverage for the failure path.

Tests: phpunit tests/phpunit/tests/admin/wpUpgrader.php (108 tests, 347 assertions).

Copilot AI review requested due to automatic review settings July 24, 2026 07:36
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

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.

Test this pull request with WordPress Playground.

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.

Pull request overview

This PR addresses upgrade/install cleanup by ensuring the extracted working directory is removed when WP_Upgrader::install_package() fails and clear_working is enabled, and adds a regression test covering that failure path.

Changes:

  • Delete the unpacked working directory in WP_Upgrader::run() when install_package() returns a WP_Error and clear_working is true.
  • Add a PHPUnit regression test to assert the working directory cleanup occurs on installation failure.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/wp-admin/includes/class-wp-upgrader.php Adds working directory cleanup in WP_Upgrader::run() for the WP_Error failure path when clear_working is enabled.
tests/phpunit/tests/admin/wpUpgrader.php Adds a regression test asserting run() deletes the working directory when install_package() fails.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/wp-admin/includes/class-wp-upgrader.php Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 24, 2026 09:20

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread tests/phpunit/tests/admin/wpUpgrader.php Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 24, 2026 10:23

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread tests/phpunit/tests/admin/wpUpgrader.php Outdated
Comment on lines +1511 to +1517
$actual = $instance->run(
array(
'package' => '/tmp/test-package.zip',
'destination' => WP_PLUGIN_DIR,
'is_multi' => true,
)
);
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 24, 2026 10:28

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 24, 2026 10:33

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

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