0

I'm debugging a Drupal 7 system I didn't setup, and I'm trying to understand how Drupal loads its modules.

This system appears to have modules nested within one other -- here's one example.

modules/custom/modulename/modulename.info
modules/custom/modulename/modulename.install
modules/custom/modulename/modulename.module
modules/custom/modulename/modulename_statistics/modulename_statistics.drush.inc
modules/custom/modulename/modulename_statistics/modulename_statistics.inc
modules/custom/modulename/modulename_statistics/modulename_statistics.info
modules/custom/modulename/modulename_statistics/modulename_statistics.module

It appears there's one module named modulename, and inside this module there's another named modulename_staticstics.

Is this a "legal/normal" setup? Does nesting one module within another confer any special features between the two modules? Where in the drupal source code are modules searched for/loaded? Is there any canonical piece of documentation that covers how module loading works? (my googling didn't turn up a lot)

(experienced software engineer here, but only passingly familiar with Drupal)

2

Is this a "legal/normal" setup?

It's perfectly legal, and yes it's normal for modules that need or want to break their functionality down that way.

Does nesting one module within another confer any special features between the two modules?

No, they’re just standard modules.

Where in the drupal source code are modules searched for/loaded?

I think this is pretty much exhaustive for Drupal 7:

  • /modules/**
  • /profiles/*/modules/**
  • /sites/*/modules/**

Is there any canonical piece of documentation that covers how module loading works?

I wouldn't have thought so - following the code is probably the best way to understand how it works. Core is pretty well commented.

| improve this answer | |
  • Thanks @clive, great answer. One follow up question -- do you know where in the source module scanning kicks off? i.e. where's a good place to start a spelunking journey. – Alan Storm Jul 9 '18 at 17:10
  • 2
    Pleasure - It's drupal_system_listing which does the scanning, happily it seems to be very well documented so that would be a good place to start – Clive Jul 9 '18 at 18:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.