(This is a Drupal 7 issue only. Drupal 8 has already fixed this problem in other ways.)
Currently in D7, drupal_system_listing() works with a more or less hardcoded list of directories, in the $searchdir variable. (A poorly named variable, btw)
Elements at the end of $searchdir have precedence. E.g. a module in ./sites/default/modules has precedence over a module in ./modules.
One thing that is currently missing is the scanning of the base profile.
Other projects may have other needs.
Unfortunately, changing this behavior in D7 would be a BC break.
Exposing a hook to alter the scanning is not a good idea either, because drupal_system_listing() is not supposed to depend on modules.
What's left is sites/*/settings.php.
(Or I hope so. drupal_system_listing() always comes after settings.php, or not? (*))
We could expose a setting that would provide a custom function to provide the base directories to scan in, such as "sites/all/".
There could even be an existing function that does include the base profile, and that only needs to be activated in settings.php.
As a preparation step, we could factor out two functions from drupal_system_listing():
_drupal_system_listing_directories($directory)
would give us the directories for the$searchdir
variable, such as "sites/all/modules"._drupal_system_listing_base_directories()
would give us the *base* directories, such as "sites/all/".
(Yes this should be with trailing slash, so that we don't have to treat Drupal root (empty string) as a special case.)
An override from settings.php would provide an alternative implementation of _drupal_system_listing_base_directories().
(*) If it turns out that settings.php does not work (e.g. during install), we could let the active profile do it instead. E.g. a flag in the profile info file.
Comment | File | Size | Author |
---|---|---|---|
#4 | D7-2503359-04-drupal_system_listing-factor-out.patch | 4.96 KB | donquixote |
#4 | D7-2503359-04-drupal_system_listing-factor-out.interdiff.txt | 1.11 KB | donquixote |
Comments
Comment #1
donquixote CreditAttribution: donquixote as a volunteer commentedComment #2
donquixote CreditAttribution: donquixote as a volunteer commentedThis patch only does the refactoring part, it does not expose anything yet.
Comment #4
donquixote CreditAttribution: donquixote as a volunteer commentedApologies everyone:
Apparently I have been looking at a modified version of Drupal core.
Someone there was creative, and added the base profile handling to drupal_system_listing(). This is not even supported in native Drupal 7.
So in my personal/local case, as this is already being modified, it would not be a huge step to change the hack for a more "correct" precedence of search directories.
The change proposed in this issue could still be useful. Not to change the precedence, but to add the base profile(s) without a hack.
Comment #5
donquixote CreditAttribution: donquixote as a volunteer commentedUpdating issue summary, because my initial explanation about precedence of base profile vs active profile was refering to a modified D7 core.