If you have a large site with CTools and many modules, like Media module or Styles module, and you're building a custom installation profile to enable all the necessary modules, you might run into situations where the installer fails. For a given module with a table "mynewtable", the error message might look like the following:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'thedatabase.mynewtable' doesn't exist
The general symptom is that the module was being installed, but before it actually created the tables from the module's hook_schema() implementation it tried to load data from one of its tables.
After a day's worth of debugging I'm starting to point the finger at CTools. While debugging Media (link above) I found that module_enable() also ran registry_update(), which causes CTools to execute ctools_registry_files_alter() and thus reload a large amount of data. Due to how the Drupal 7 module installation process works, when ctools_registry_files_alter() executes the system has loaded the new mymodule.module file, has all of its hook implementations available but has not actually installed it yet, so hook implementations that query against its custom tables will fail. This can lead to the module's installation to fail and thus cause installation profiles to fail.
I've submitted a core issue to change how module_enable() works, but perhaps there's something ctools itself could do?
Comments
Comment #1
merlinofchaos commentedI don't really see how CTools would be able to tell. :/
Comment #2
Ashlar commentedComment #2.0
Ashlar commentedCorrect Media.module issue URL.