Skip to content

[codex] support plugin ZIP updates - #358

Merged
fabiodalez-dev merged 3 commits into
mainfrom
codex/plugin-zip-updates
Aug 19, 2026
Merged

[codex] support plugin ZIP updates#358
fabiodalez-dev merged 3 commits into
mainfrom
codex/plugin-zip-updates

Conversation

@fabiodalez-dev

Copy link
Copy Markdown
Owner

Problema

L'upload di un file ZIP con il nome di un plugin già installato veniva bloccato sia dal controllo della riga esistente nel database sia dalla directory già presente su disco. Per aggiornare un plugin era quindi necessario disinstallarlo, con il rischio di perdere configurazione, dati e hook associati.

Causa ed effetto

PluginManager::installFromZip() trattava ogni ZIP esclusivamente come una nuova installazione. Il controllo anticipato del nome e quello della directory restituivano entrambi un errore prima che il pacchetto potesse essere validato o sostituito.

Correzione

Il flusso ora riconosce un nome già registrato come aggiornamento in-place. Il pacchetto viene estratto in una directory temporanea, validato (incluso il percorso di main_file) e promosso solo quando è completo. Per un aggiornamento, la directory corrente viene rinominata come backup, quella in staging viene promossa in modo atomico e i metadati del manifest vengono aggiornati sullo stesso record plugins.

L'ID del plugin, lo stato di attivazione, le impostazioni, i dati, gli hook e i log non vengono modificati. Se la sostituzione o l'aggiornamento dei metadati falliscono, il pacchetto precedente viene ripristinato. Le cache dei plugin vengono invalidate dopo l'aggiornamento riuscito.

È stato inoltre aggiunto un gate che verifica tutti i manifest e i file principali dei plugin distribuiti, oltre a un test di integrazione che installa e aggiorna un plugin ZIP temporaneo controllando la preservazione di ID, stato, impostazioni, dati e hook.

Verifica

  • php tests/plugin-zip-update.integration.php
  • php tests/plugin-package-contract.unit.php
  • php tests/plugin-manager.unit.php
  • php tests/plugin-schema-expectations-static.unit.php
  • php tests/plugin-schema-guard.unit.php
  • controllo di sintassi su tutti i 225 file PHP dei plugin
  • npm test
  • composer validate --no-check-publish
  • npm run test:ci-policy
  • hook di commit PHPStan: nessun errore

@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d1cbe06a-0511-44f5-b91a-9f5efb30f4a0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

PHPStan level 5 flagged $pluginMeta['name'] ?? 'unknown' as dead code — the
'name' offset is guaranteed on the validated $pluginMeta array (every other use
in this method reads it directly). Remove the coalesce to match.
The synthetic integration test covers install→update on one disposable
plugin. This adds an all-bundled test that, for each of the plugins under
storage/plugins/, packages its real files with a bumped manifest version,
runs installFromZip() through the in-place-update branch, and asserts the
plugin id stays stable, the files are promoted and the new version is
persisted — then restores the directory byte-for-byte and the plugins-row
version so the database and working tree are left exactly as found.

Both integration tests are now wired into the DB-backed ci-quality job
(they were only runnable by hand before). The job already loads the base
schema + Italian data and registers every bundled plugin, so the tests run
against the same baseline as a completed install. Verified locally: 20/20
plugins pass and no -ziptest version or directory change is left behind.
fabiodalez-dev added a commit that referenced this pull request Aug 19, 2026
@fabiodalez-dev
fabiodalez-dev merged commit 9ae94b0 into main Aug 19, 2026
36 of 37 checks passed
fabiodalez-dev added a commit that referenced this pull request Aug 19, 2026
…dening

The 0.7.62 entry covered the plugin ZIP-update feature (#358) but not the
lifecycle correctness added while hardening it: an active plugin's update now
runs its new onActivate()/ensureSchema() on the next request with rollback on
failure, and the release verifiers reject any non-.gitkeep storage/sessions
entry. Document both under 0.7.62 so the release notes are complete.
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.

1 participant