fix: require nimbuscms/nimbus at runtime, not only in development - #2
Merged
Merged
Conversation
The plugin's production classes implement Nimbus interfaces — Plugin, PluginContext, FieldType, Field — but core was listed under require-dev. Composer would therefore have installed this package without checking that a compatible Nimbus was present, and the failure would have surfaced as a class not found at boot rather than as a resolution error at install time. Also adopts the narrowed registrar API from core: the plugin no longer passes its own provider id, because the loader binds it. A plugin that could name its own provider could name someone else's. Adds PackageIntegrationTest, which proves the package boundary rather than the field. It drives the real PluginLoader with this package's real manifest: discovery registers the type into the shared registry under this plugin's id and leaves core types alone; disabling leaves it unregistered; with it disabled write paths refuse the type while the admin still shows the stored source and blocks saves; re-enabling restores it; and a second package cannot take this plugin's id.
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.
Two fixes and a new test class, from the core audit.
The packaging bug
"require": { "php": ">=8.2", "ext-mbstring": "*", + "nimbuscms/nimbus": "dev-main" }, "require-dev": { "phpstan/phpstan": "^2.2", - "phpunit/phpunit": "^11.0", - "nimbuscms/nimbus": "dev-main" + "phpunit/phpunit": "^11.0" }This package's production classes implement
Plugin,PluginContext,FieldTypeandField. With core inrequire-dev, Composer would install this package without checking a compatible Nimbus was present — and the failure would show up as a class-not-found at boot rather than a resolution error at install time, which is much harder to diagnose.The registrar API
Adopts the narrowed capability from nimbus#18:
The loader binds the provider id now. A plugin that could name its own provider could name someone else's — and since rollback is provider-scoped, that was a way to get another provider's types removed.
PackageIntegrationTest
MarkdownFieldTypeTestproves the field behaves correctly when handed a value. This proves something different and easier to get wrong: that a real Composer installation of this package is discovered by Nimbus's own loader, using this package's real manifest, and registers with nobody editing core.Everything is the genuine article — the installed
composer.json, the realPluginLoader, the realFieldTypeRegistry. Only the path toinstalled.jsonis synthesised, because Composer writes that file about the root project and this package is the root when its own tests run.Covers: manifest declares core at runtime and is typed
nimbuscms-plugin· discovery registers into the shared registry under this plugin's id · core types untouched · disabling leaves it unregistered with a non-failure diagnostic · with it disabled, write paths refuse the type while the admin still shows the stored source and blocks saves · re-enabling restores it · a second package cannot take this plugin's id.dev-mainstays for now — the path to^0.1is tracked under Release & packaging in the core roadmap.🤖 Generated with Claude Code