Skip to content

Fix: sync plugin name from composer.json on update#436

Draft
simonhamp wants to merge 1 commit into
mainfrom
fix-plugin-name-update
Draft

Fix: sync plugin name from composer.json on update#436
simonhamp wants to merge 1 commit into
mainfrom
fix-plugin-name-update

Conversation

@simonhamp

Copy link
Copy Markdown
Member

Problem

When a plugin submission was updated (via GitHub push/release webhooks or an admin re-sync), the plugin's name was never refreshed from its composer.json. If a maintainer renamed their package, the database kept the old name.

Cause

In PluginSyncService::sync(), the name-sync block was guarded by ! $plugin->name:

if (isset($composerData['name']) && ! $plugin->name) {

That guard only allowed the name to be set when a plugin had no name yet (i.e. at creation time). On every subsequent sync the plugin already had a name, so the block was skipped.

Fix

Update the name whenever composer.json's name differs from the stored value:

if (! empty($composerData['name']) && $composerData['name'] !== $plugin->name) {
  • Renames now flow through on update.
  • The initial-creation flow still works (null name → differs → set).
  • The existing uniqueness guard is preserved: a name already used by another plugin is not stolen (it logs a warning instead).
  • Switched isset()! empty() so a blank/missing name can't wipe an existing one.

Tests

Added three feature tests to PluginSyncServiceTest:

  • test_sync_updates_name_from_composer_when_name_changes — the core fix.
  • test_sync_sets_name_on_initial_sync_when_plugin_has_no_name — protects the creation flow.
  • test_sync_does_not_overwrite_name_when_taken_by_another_plugin — verifies the uniqueness guard.

All sync-related suites pass (55 tests). Pint is clean.

Note

Changing a plugin's name also affects is_official, the Satis package name, and the vendor/package URL. This PR syncs the DB field only; re-registering/renaming the Satis package on rename would be a sensible follow-up.

🤖 Generated with Claude Code

The name-sync guard only set the name when a plugin had none yet, so
webhook (push/release) and admin re-syncs never picked up a renamed
package. Update the name whenever composer.json's name differs, keeping
the uniqueness guard and ignoring blank names.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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