Skip to content

Let app plugins override vendor plugins again - #86

Merged
dereuromark merged 2 commits into
2.xfrom
fix-app-plugin-priority
Oct 10, 2026
Merged

dereuromark merged 2 commits into
2.xfrom
fix-app-plugin-priority

Conversation

@dereuromark

@dereuromark dereuromark commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Fixes #85.

Since 2.0.2 a vendor plugin wins over an app plugin of the same name in cakephp-plugins.php. Up to 2.0.1 it was the other way around, which is what lets you keep a working copy of a plugin in plugins/ while it is also installed through composer.

The refactor in #80 switched the merge to $plugins += ..., and an array union keeps the key that is already there, here the vendor one. The app plugins are now collected first and merged over the vendor plugins.

Vendor-namespaced plugins needed a second change. A composer package was keyed Vendor\Plugin and the app plugin Vendor/Plugin, so both survived findPlugins() and writeConfigFile() wrote the same key twice, vendor entry last. findPlugins() now returns vendor packages with / in the key too.

One difference to 2.0.1 remains, on purpose: if the same plugin sits in more than one plugin-paths directory, the first directory wins (2.0.1 took the last). preAutoloadDump() has always registered the PSR-4 namespace of the first directory, so going back to "last wins" would load classes from one directory and resources from the other.

Since 2.0.2 the app plugins were merged with an array union that kept
an already registered vendor plugin of the same name, so a plugin in
plugins/ no longer replaced its composer-installed copy in
cakephp-plugins.php. Collect the app plugins first and merge them over
the vendor ones.

When the same plugin exists in several plugin paths the first path
still wins, which matches the PSR-4 entries preAutoloadDump() registers.
@dereuromark dereuromark added this to the 2.0.x milestone Oct 10, 2026
@codecov

codecov Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.35%. Comparing base (2084f45) to head (624fdde).

Additional details and impacted files
@@             Coverage Diff              @@
##                2.x      #86      +/-   ##
============================================
+ Coverage     82.11%   82.35%   +0.23%     
  Complexity       48       48              
============================================
  Files             1        1              
  Lines           151      153       +2     
============================================
+ Hits            124      126       +2     
  Misses           27       27              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

A composer package is keyed by its namespace (Vendor\Plugin), an app
plugin by its directory (Vendor/Plugin). The two never collided in
findPlugins(), and writeConfigFile() then wrote both under the same
normalized key, where the vendor entry came last and won. Key vendor
packages with a forward slash as well so the app plugin replaces them.

Document the priority in the README.
@dereuromark
dereuromark merged commit 5c0484b into 2.x Oct 10, 2026
8 checks passed
@dereuromark
dereuromark deleted the fix-app-plugin-priority branch October 10, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vendor plugins are taking priority over app-plugins when loading

2 participants