Delete legacy mu-plugin files that lived in site filesystem#2655
Merged
Delete legacy mu-plugin files that lived in site filesystem#2655
Conversation
Older Studio versions wrote mu-plugin PHP files directly into wp-content/mu-plugins/. Newer versions inject them at runtime via the PHP WASM virtual filesystem. Having both causes "Cannot redeclare" PHP fatal errors. This adds a cleanup step that removes known legacy files before starting the server or running WP-CLI commands. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…cleanup-legacy-mu-plugins
epeicher
approved these changes
Feb 25, 2026
Contributor
epeicher
left a comment
There was a problem hiding this comment.
Thanks @sejas for solving this, and thanks for the detailed testing instructions! I have tested it, and I confirm that the deprecated files are deleted after starting Studio as expected. Changes also LGTM! ![]()
| Before starting Studio | After starting Studio |
|---|---|
![]() |
![]() |
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.


Related issues
Proposed Changes
Sites created with older Studio versions (e.g June 2024) have physical
0-*.phpmu-plugin files inwp-content/mu-plugins/. Newer Studio versions inject the same mu-plugins at runtime via the PHP WASM virtual filesystem (/internal/studio/mu-plugins/). When both copies exist, PHP encounters fatal errors likeCannot redeclare check_current_theme_availability().This PR adds a
cleanupLegacyMuPlugins()function that removes known legacy Studio mu-plugin files from the site'swp-content/mu-plugins/directory before starting the WordPress server or running WP-CLI commands.Changes:
cleanupLegacyMuPlugins(sitePath)intools/common/lib/mu-plugins.tswith an allowlist of 22 known legacy filenames (current + retired)wordpress-server-child.tsbefore building CLI argsrun-wp-cli-command.tsbefore mounting mu-pluginsTesting Instructions
wp-content/mu-plugins/directory:wp-content/mu-plugins/rayden-muplugins-remove.mp4
Pre-merge Checklist