Skip to content

J6.1 plugin constructor: drop DispatcherInterface arg (deprecation)#12

Merged
bcordis merged 1 commit into
developfrom
claude/plugin-constructor-j61
Apr 30, 2026
Merged

J6.1 plugin constructor: drop DispatcherInterface arg (deprecation)#12
bcordis merged 1 commit into
developfrom
claude/plugin-constructor-j61

Conversation

@bcordis
Copy link
Copy Markdown
Member

@bcordis bcordis commented Apr 30, 2026

Tracks #11. Updates references/plugin.md and references/service-provider.md for the Joomla 6.1 CMSPlugin::__construct change.

Background

Joomla 6.1 (released 2026-04-14) deprecates passing a DispatcherInterface to the plugin constructor:

Passing an instance of Joomla\Event\DispatcherInterface to Joomla\CMS\Plugin\CMSPlugin::__construct() will not be supported in 7.0. Starting from 7.0 CMSPlugin class will no longer implement DispatcherAwareInterface.

— from libraries/src/Plugin/CMSPlugin.php on 6.1-dev, tracked in PR #46683.

The skill's previous example (still on develop until this PR lands) instantiated plugins as new Example($dispatcher, $config) — that form now emits E_USER_DEPRECATED on every plugin load on 6.1+, and breaks outright in 7.0.

What changed

  1. references/plugin.md service-provider example — single-arg instantiation, no DispatcherInterface import or container lookup. Matches the plg_captcha_powcaptcha reference plugin in core.
  2. New "Joomla 6.0 / 6.1 / 7.0 — dispatcher constructor change" callout in references/plugin.md quoting the deprecation message, citing the source permalink, documenting the legacy two-arg form for J5/J6.0 backward compat, and explaining what to do if a plugin actually needs to dispatch its own events (implement DispatcherAwareInterface directly; CMSPlugin won't provide that wiring in 7.0).
  3. references/plugin.md plugin class — removed the dead use Joomla\Event\DispatcherInterface; import (only ever there for the old constructor's typed parameter).
  4. references/service-provider.md — plugin row in the per-type registration table updated: plugins use no Service\Provider\* factory shorthand; the provider just news the class with $config. Forward-pointer to plugin.md for the full deprecation story.

What I deliberately did NOT do

  • Touch module.md — it was not affected by #46683. Module dispatchers aren't CMSPlugin.
  • Patch the J5/J6.0 path — the legacy two-arg form still works on 6.1; users targeting older Joomla can keep it (with the deprecation warning) or pick a 6.1+ floor and use the new form.
  • Sweep all other 6.1 milestone items — those land per audit issue (Audit: references/module.md #3 module / Audit: references/plugin.md #4 plugin / etc.). This PR is focused on the one item that already had stale code in the skill.

Test plan

  • bash scripts/validate.sh passes.
  • Verified the new pattern against joomla-cms 6.1-dev source: CMSPlugin::__construct($config = []) accepts the single-arg form cleanly; the instanceof DispatcherInterface check is only the deprecation path for legacy callers.
  • Verified against the migrated plg_captcha_powcaptcha provider in core — same pattern.
  • CI validate.yml workflow green.
  • Manual smoke test: build a tiny content plugin against J6.1 with the new pattern, confirm no deprecation warnings on plugin load.

Generated by Claude Code

Joomla 6.1 (released 2026-04-14) deprecates the DispatcherInterface
parameter on CMSPlugin::__construct. Old-style two-arg calls still
work but emit E_USER_DEPRECATED and will be removed in J7.0.

Verified against:
- joomla-cms PR #46683 ("[6.1] Remove use of deprecated dispatcher
  from the plugin constructor")
- libraries/src/Plugin/CMSPlugin.php on 6.1-dev (constructor now
  takes only $config; instanceof DispatcherInterface check is the
  legacy compat path that triggers the deprecation)
- plugins/captcha/powcaptcha/services/provider.php on 6.1-dev
  (single-arg instantiation, then ->setApplication(...))

Edits:
- references/plugin.md service-provider example: drop the
  DispatcherInterface import and the $container->get() lookup;
  instantiate with just (array) PluginHelper::getPlugin($group,
  $element). Added a "Joomla 6.0 / 6.1 / 7.0" callout that quotes
  the deprecation message verbatim, links the 6.1-dev source, and
  documents the legacy two-arg form for J5/J6.0 backward compat
  with the trade-off spelled out.
- references/plugin.md plugin class example: remove the now-dead
  use Joomla\Event\DispatcherInterface; — only ever there for the
  old constructor's typed parameter.
- references/service-provider.md plugin-row in the "what each
  extension type registers" table: plugins use no
  Service\Provider\* factory shorthand; the provider just news the
  class with $config. Added the J6.0 → J6.1+ deprecation note
  pointing at plugin.md for full details.

Captured in CHANGELOG [Unreleased] § Fixed.

Issue #11 is the coordination point for the rest of the J6.1
sweep (branch names in canonical sources, <targetplatform>
regexes, new-feature coverage).
@bcordis bcordis merged commit bf647ef into develop Apr 30, 2026
1 check passed
bcordis added a commit that referenced this pull request Apr 30, 2026
… verification (#13)

Closes #3.

- Cross-references to all four shared refs added (manifest, language-files,
  service-provider, install-script). New Language Files section, new Install
  Script (Optional) section, intros on Manifest XML and Service Provider.
- Web Asset Manager registration subsection inside Dispatcher (useStyle/
  useScript against joomla.asset.json, Text::script() registration).
- Caching section (default per-instance keying, URL- and session-state
  edge cases, no dispatcher-level public cache-key hook).
- Joomla 6.1 capabilities section (Versions for Modules / UCM history,
  #__extensions.custom_data column).
- Verified AbstractModuleDispatcher and mod_articles_news provider against
  joomla-cms 6.1-dev — both unchanged for 6.1; permalinks captured.
- Module dispatchers don't extend CMSPlugin, so the J6.1 plugin-constructor
  deprecation (#12) does not affect modules.

CHANGELOG [Unreleased] updated under issue #3 audit subsection.
bcordis added a commit that referenced this pull request Apr 30, 2026
…oloadLanguage, pitfalls, J6.1 verify (#14)

Closes #4.

Bug fixes:
- Manifest <language> path was en-GB/plg_content_example.ini (legacy
  admin-installed naming). Fixed to en-GB/en-GB.plg_content_example.ini
  (locale-prefixed source-tree naming) per language-files.md. Added the
  missing .sys.ini line — most plugins ship both runtime and .sys.ini.
- Plugin class example now declares protected $autoloadLanguage = true;
  Without it, runtime PLG_* keys render as raw strings.

Cross-references to shared refs (cross-cutting principle from #2):
- Manifest XML and Service Provider sections get cross-link intros.
- New Language Files section: PLG_<GROUP>_<ELEMENT>_*, locale-prefix rule,
  $autoloadLanguage requirement, task-plugin _TITLE/_DESC suffix rule.
- New Install Script (Optional) section pointer to install-script.md.

New Common Pitfalls section covering seven highest-frequency plugin
install/load failure modes.

J6.1 verification (continuous):
- getSubscribedEvents() shape verified against plg_content_pagebreak on
  6.1-dev — string event-name keys, no class constants.
- ContentEvent abstract base on 6.1-dev confirmed to deliberately NOT
  define ON_* constants. Typed event classes (ContentPrepareEvent etc.)
  exist only as handler-parameter types, not as keys for
  getSubscribedEvents().
- Initial audit flagged events-as-strings as drift; upstream verification
  shows the skill's pattern matches core. Docblock added explaining the
  distinction.

Dispatcher-constructor change from PR #12 unchanged — that callout was
already correct.

CHANGELOG [Unreleased] updated under issue #4 audit subsection.
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.

2 participants