Ensure plugin, theme, and WordPress updates succeed #1431
Closed
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.
What is this PR doing?
This PR ensures plugin, theme, and WordPress updates always succeed.
What problem is it solving?
Issues related to updates can be reproduced in the Studio app, wp-now, and Playground CLI. Specifically, attempting to update outdated versions of WordPress, plugins, or themes results in an error when using any of the aforementioned tools.
Studio issues: https://github.com/Automattic/dotcom-forge/issues/6891, Automattic/studio#100
wp-now issue: WordPress/playground-tools#178
How is the problem addressed?
With this PR, we add
old_node.parent = new_dir
to thefinally
block in therename
handler to ensure the parent node is correctly updated, even if it's not correctly handled during the rename operation.Although this shouldn't technically be necessary, as the parent is also set here as part of the
try
block, I believe some of the differences in file systems and types can contribute to inconsistency. To understand this, it's important to have the following context to this problem:rename()
as part of its installation and update processes here.rename()
functionality was commented out or after adding$this->is_file( $source ) &&
to the conditional.By explicitly updating the parent node in the
finally
block, we guarantee consistent filesystem state and proper handling of directories across different scenarios.Testing Instructions
To test these changes, first use Playground CLI to spin up a local WordPress environment. In my case, I used an existing WordPress installation in my local Studio directory and the following command.
/../Studio/my-wordpress-website
should be updated to point to your specific local installation:Update an outdated plugin
Tip
I encountered a persistent error when attempting to install the Jetpack plugin using Playground CLI. It was possible to reproduce this against
trunk
, as such I recommend using other plugins for testing.Recording:
updates.mov
Update an outdated version of WordPress
Recording:
wordpress-update.mov
General smoke testing
Ensure no regressions by testing general functionality related to installations. It should still be possible to install plugins and themes as before.