Repository navigation
Let app plugins override vendor plugins again - #86
Merged
Merged
Conversation
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.
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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.
ADmad
approved these changes
Oct 10, 2026
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.
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 inplugins/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\Pluginand the app pluginVendor/Plugin, so both survivedfindPlugins()andwriteConfigFile()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-pathsdirectory, 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.