Problem/Motivation
It is currently impossible to put modules in ./modules/vendor. In ./modules/README.txt it says:
ORGANIZING MODULES IN THIS DIRECTORY
------------------------------------
You may create subdirectories in this directory, to organize your added modules,
without breaking the site. Some common subdirectories include "contrib" for
contributed modules, and "custom" for custom modules. Note that if you move a
module to a subdirectory after it has been enabled, you may need to clear the
Drupal cache so it can be found.
However, this isn't completely true, you cannot name your subdirectories anything that is on the blacklist:
/**
* List of directory names to skip when recursing.
*
* These directories are globally ignored in the recursive filesystem scan;
* i.e., extensions (of all types) are not able to use any of these names,
* because their directory names will be skipped.
*
* @var array
*/
protected $blacklist = array(
// Object-oriented code subdirectories.
'src',
'lib',
'vendor',
// Front-end.
'assets',
'css',
'files',
'images',
'js',
'misc',
'templates',
// Legacy subdirectories.
'includes',
// Test subdirectories.
'fixtures',
// @todo ./tests/Drupal should be ./tests/src/Drupal
'Drupal',
);
This is actually a regression from Drupal 7 which allows modules to be placed in a "vendor" subdirectory.
Proposed resolution
Allow folders in the blacklist to exist when they are direct descendants of one of the extension directories (modules, themes, and profiles). There shouldn't be a problem with doing this, as direct decedents should always contain more modules rather than arbitrary code (that would exist in a folder of a module itself).
Alternatively, we should update the documentation to reflect the blacklisted subfolder names, but I think it would be better to allow the names.
Remaining tasks
- Write Patch
User interface changes
None
API changes
None. Other than that direct descendants of extension folders must be subfolders and not contain arbitrary 3rd-party code. I think this is already expected.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#4 | modules_cannot_be_put-2532148-4.patch | 611 bytes | timmillwood |
Comments
Comment #1
davidwbarratt CreditAttribution: davidwbarratt as a volunteer and commentedComment #2
davidwbarratt CreditAttribution: davidwbarratt as a volunteer and commentedComment #3
timmillwoodI've been looking into this.
It looks as though
ExtensionDiscovery::scan
is where most of the work is done. This then callsExtensionDiscovery::scanDirectory
I'm not sure there is a simple way to implement the "Proposed resolution" without reworking a lot of this.
The attached patch is a proposed modules/README.txt change explaining the ignored directory names.
Comment #4
timmillwoodNow under 80 characters per line.
Comment #5
dawehnerFor me its not obvious that these are folders inside a module itself? So this is about any folder name recursively in /modules?
Comment #6
davidwbarratt CreditAttribution: davidwbarratt commented#5,
That's correct. According to the code, it is recursive. Ideally I think it would be better to ignore the blacklist for direct descendants of
./modules
but that might not be possible.Comment #7
dawehnerAh great. Do we mind making that a little bit more explicit in the documentation?
Comment #8
skwashd CreditAttribution: skwashd at Dave Hall Consulting for Pfizer, Inc. commented@dawehner I have read over the docs as proposed by @timmillwood and it is pretty clear to me.
Comment #9
dawehnerOkay, cool, well I'm not native, so my filter is always a little bit different. RTBC
Comment #10
alexpottCommitted bd6afc1 and pushed to 8.0.x. Thanks!
I think the added documentation makes sense.
Comment #12
loopduplicateThis might be getting overly picky, but shouldn't we use double quotes in documentation? I think devs get used to using single quotes (apostrophes) in code but we shouldn't use them to replace quotes in English.