Problem/Motivation
The \Drupal\Core\Extension\ExtensionDiscovery class documentation implies that you can control whether or not extensions underneath a profile directory will be scanned or not. But this is not actually true, unless you fake it.
There are two ways to set the $profileDirectories member variable explicitly. One is in the constructor, and another is by calling the setProfileDirectories() method. The documentation for the member variable, constructor param, and method say:
- Member variable: List of installation profile directories to additionally scan.
- Method: Sets explicit profile directories to scan. // A list of installation profile directory paths relative to the system root directory (without trailing slash) to search for extensions.
- Constructor: The available profile directories
All of these imply (at least to me) that if you set this to an empty directory, no profile directories should be scanned for modules.
However, what actually happens if you set this to an empty directory is that all profile directories are scanned.
What you can actually do in order to forbid profile directories from being scanned for modules is set it to something like ['foo']
, so that it will only scan the non-existent "foo" profile. However, if you do that when you are scanning for profiles themselves, nothing will be returned.
Proposed resolution
Either:
a) Fix the documentation so it matches the behavior.
or
b) Fix the code so that if you pass in an empty directory (as opposed to NULL), no profile directories are scanned for modules/themes.
Decided on (a). See comment #7 for why (b) seemed too dangerous.
Remaining tasks
Decide and patch and test.
User interface changes
None.
API changes
None. Patch contains documentation and local/protected variable name changes only.
Data model changes
None.
Release notes snippet
None.