Repository navigation
Conversation
… rollback Stage the new version, move the installed entries to a backup directory, swap via rename and restore the previous version if anything fails. Add tests for the success and failure paths.
Arm a shutdown handler during the swap so a fatal error or timeout restores the previous version. Use core's move_dir(), check free disk space, enable maintenance mode while swapping and reject non-direct filesystems and packages without version header. Add tests including a real fatal error in a child process. Bean: vnzi
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Rollback bookkeeping can lose backups or leave mixed installations, and package validation accepts an invalid plugin-directory type.
3 open issues
What changed in this PR
Refactors ionos-core MU-plugin updates to use staging, backups, and rollback instead of overwriting live files.
Changes:
- Adds package, disk-space, and filesystem checks.
- Introduces maintenance-mode swaps and shutdown recovery.
- Adds update failure tests, including a fatal-error subprocess.
| File | Description |
|---|---|
packages/wp-mu-plugin/ionos-core/ionos-core/update/tests/phpunit/MuPluginUpgraderTest.php |
Tests updates, validation, rollback, and filesystem moves. |
packages/wp-mu-plugin/ionos-core/ionos-core/update/tests/phpunit/fixtures/fatal-during-swap.php |
Triggers a fatal error during installation. |
packages/wp-mu-plugin/ionos-core/ionos-core/update/class-mu-plugin-upgrader.php |
Implements staged installation and recovery. |
.beans/vnzi--ionos-core-harden-mu-plugin-update-staging-backup.md |
Records implementation scope and recovery limitations. |
Review effort: Balanced
…upted moves Validate package entry types and record backup/install attempts before moving, rolling back from the actual disk state. Refs vnzi.
lgersman
marked this pull request as draft
October 26, 2026 09:49
This branch has not been deployed
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.

Beschreibung
Baut das Update des ionos-core MU-Plugins (
MU_Plugin_Upgrader) so um, dass nach einem fehlgeschlagenen oder abgebrochenen Update wieder die alte Version installiert ist. Bezieht sich auf die Kriterien „clear destination instead of copydir“ und „test update behavior“ aus dem Ticket zu #956.Bisher hat
copy_dir()direkt im Live-Verzeichnis überschrieben. Ein Abbruch mittendrin hinterließ eine Mischung aus alter und neuer Version, und veraltete Dateien wurden nur nachträglich und ungesichert gelöscht.Ablauf in
MU_Plugin_Upgrader::install()ionos-core/undionos-core.phpmüssen vorhanden sein,ionos-core.phpbraucht einenVersion-Header. Außerdem muss genug Speicherplatz frei sein (mindestens das Doppelte der Paketgröße) und das Dateisystemdirectsein.mu-plugins/.ionos-core-staging-<id>/kopiert. Bis hierhin ist das Live-Plugin unberührt.move_dir()nach.ionos-core-backup-<id>/verschoben, danach die gestagten Einträge ins Ziel. Währenddessen ist der Maintenance-Mode aktiv.shutdown-Hook registriert (restore_on_shutdown()), der auch bei einem Fatal Error oder Timeout die alte Version wiederherstellt.Bewusst nicht den Core-Mechanismus verwendet
WP_Upgrader::install_package()mitclear_destinationeignet sich nicht fürmu-plugins: Core schützt dort nurABSPATH,WP_CONTENT_DIR,WP_PLUGIN_DIRund die Theme-Verzeichnisse, nichtWPMU_PLUGIN_DIR. Das Leeren des Ziels würde alle anderen MU-Plugins löschen. Von Core übernommen sindmove_dir(), der Maintenance-Mode und die Idee des Rollbacks aufshutdown.Bekannte Grenzen
shutdown-Hook nicht. Dann bleibt.ionos-core-backup-*liegen und das Plugin kann fehlen. Eine automatische Wiederherstellung gibt es nicht.direct(der alte Code funktionierte mit lokalen Pfaden auch nur dort). Andere Methoden werden mit einer eindeutigen Fehlermeldung abgelehnt.Checklist
Zu den Acceptance Criteria: Die Kriterien „clear destination instead of copydir“ und „test update behavior“ sind mit diesem PR abgedeckt. Der Rest des Tickets liegt in #956, und die Frage der Loop-Daten-Synchronisation ist dort noch offen.
manual testing
Die Tests laufen mit
pnpm test:php --php-opts "--filter MuPluginUpgraderTest". Sie decken ab: erfolgreiches Update, ungültiges Paket, fehlendes Versions-Header, zu wenig Speicherplatz, falsches Dateisystem, Fehler beim Backup und beim Installieren mit Rollback, fehlgeschlagenen Rollback, Maintenance-Mode, Verschieben über Dateisystemgrenzen und einen echten Fatal Error mitten im Swap (separater PHP-Prozess,tests/phpunit/fixtures/fatal-during-swap.php).Reviewer checklist