Skip to content

Run global plugins in the compiled interceptor's default branch (#28) - #32

Open
pingiun wants to merge 1 commit into
creatuity:masterfrom
pingiun:fix/global-plugins-in-default-scope
Open

Run global plugins in the compiled interceptor's default branch (#28)#32
pingiun wants to merge 1 commit into
creatuity:masterfrom
pingiun:fix/global-plugins-in-default-scope

Conversation

@pingiun

@pingiun pingiun commented Jul 17, 2026

Copy link
Copy Markdown

Compiled interceptors put the last-grouped scope in the switch default branch, so plugins declared in the global etc/di.xml were skipped in CLI/primary and any scope not explicitly enumerated (crontab, webapi_rest, webapi_soap, graphql, custom scopes). Standard Magento merges the global config into every scope, so those plugins must always fire.

This drives the default branch from the global plugin chain (always aggregating primary+global, independent of Scope::getAllScopes()) and emits an explicit case only for scopes whose merged chain differs. A class with only global plugins collapses to a plain, switch-free body. Includes a unit test.

Fixes #28.

🤖 Generated with Claude Code

Compiled interceptors emitted a `switch (getCurrentScope())` whose `default`
branch was whatever scope happened to be grouped last - often an area chain, or
a parent-direct fall-through - so plugins declared in the global etc/di.xml were
skipped in CLI/primary and in any scope not explicitly enumerated (crontab,
webapi_rest, webapi_soap, graphql). Standard Magento merges the global config
into every scope, so those plugins must always fire.

- AreasPluginList::getPluginsConfigForAllAreas() now always includes the
  `primary` and `global` scopes, regardless of what Scope::getAllScopes()
  returns on a given Magento version.
- CompiledInterceptor now drives the `switch` `default` branch from the GLOBAL
  scope's plugin chain and emits an explicit `case` only for scopes whose merged
  chain differs from global. A class with only global plugins collapses to a
  plain, switch-free body that always runs them.

Adds Test/Unit/CompiledInterceptor/ScopeCasesTest.php locking that the global
chain drives `default`, that scopes equal to global collapse into it, and that
genuinely area-only plugins keep a parent-direct default.

Fixes creatuity#28

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pingiun

pingiun commented Jul 17, 2026

Copy link
Copy Markdown
Author

@jakwinkler I made this commit blind, although Claude is confident in it 😬. What do you think of it?

@jakwinkler

Copy link
Copy Markdown

Looks good but I am not the one who can merge it :-)

@pingiun

pingiun commented Jul 17, 2026

Copy link
Copy Markdown
Author

Yeah just wanted to check since you opened the issue

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.

Compiled interceptors do not fire plugins in CLI (primary/global scope)

2 participants