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

  1. 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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

davidwbarratt’s picture

Issue summary: View changes
davidwbarratt’s picture

Issue summary: View changes
timmillwood’s picture

Status: Active » Needs review
FileSize
608 bytes

I've been looking into this.

It looks as though ExtensionDiscovery::scan is where most of the work is done. This then calls ExtensionDiscovery::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.

timmillwood’s picture

Now under 80 characters per line.

dawehner’s picture

+++ b/modules/README.txt
@@ -22,6 +22,10 @@ contributed modules, and "custom" for custom modules. Note that if you move a
+There are number of directories that are ignored when looking for modules. These

For me its not obvious that these are folders inside a module itself? So this is about any folder name recursively in /modules?

davidwbarratt’s picture

#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.

dawehner’s picture

Ah great. Do we mind making that a little bit more explicit in the documentation?

skwashd’s picture

Status: Needs review » Reviewed & tested by the community

@dawehner I have read over the docs as proposed by @timmillwood and it is pretty clear to me.

dawehner’s picture

Okay, cool, well I'm not native, so my filter is always a little bit different. RTBC

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed bd6afc1 and pushed to 8.0.x. Thanks!

I think the added documentation makes sense.

  • alexpott committed bd6afc1 on 8.0.x
    Issue #2532148 by timmillwood, davidwbarratt: Modules cannot be put in...
loopduplicate’s picture

+++ b/modules/README.txt
@@ -22,6 +22,10 @@ contributed modules, and "custom" for custom modules. Note that if you move a
+are 'src', 'lib', 'vendor', 'assets', 'css', 'files', 'images', 'js', 'misc',
+'templates', 'includes', 'fixtures' and 'Drupal'.

This 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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.