webchick noted problems installing cck with an install profile, and I encountered similar problems with the views module.

Investigation revealed that the installer chokes when asked to install any module in the sites/all/modules, /profiles/$pofile/modules, and sites/$current_site/modules directories. Only the system module properly locates modules and themes.

The attached patch moves the logic for finding the correct directories to bootstrap.inc, where the initial install system can use it. Some further improvements will be necessary to complete the process (it still only triggers .install files in the root modules directory, but as of right now it properly *finds* modules in any location).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chx’s picture

This belongs to common.inc not bootstrap.inc. Note that file.inc is only loaded from common.inc . Consider moving the code to file.inc , even as it's file related...

eaton’s picture

Good point, this is purely reltaed to directory traversal and file discover. Will move it, thanks.

eaton’s picture

FileSize
7.89 KB

Here's a slightly updated version of the code, with the helper function moved to file.inc.

chx’s picture

Status: Needs work » Needs review
Dries’s picture

Can we add some code comments to the changes in install.inc? Thanks!

eaton’s picture

Definitely. I still need to hammer out a remaining issue -- the initial installation process doesn't properly install modules in the /profiles/$profile/modules directory. It works fine once the installation is done and the user visits admin/modules.

eaton’s picture

FileSize
8.22 KB

Installing modules from the profile directory now works, and some commenting has been added to install.inc to make the various steps easier to understand. Yay!

moshe weitzman’s picture

not a big deal, but i don't really agree that the listing function should be in file.inc. file_scan_directory is good there, but file_system_listing is about the drupal module/theme API, not file maangement. i vote for common.inc

more substantive review later, i hope.

eaton’s picture

FileSize
8.37 KB

Chatted with chx, and he agreed that since this deals specifically with theme/module/etc traversal it would make sense in common.inc. This version of the patch renames the function to drupal_system_listing() and locates it in common.inc.

Dries’s picture

I don't like the global $profile.

eaton’s picture

Dries, after doing some further investigation, I don't think there's really any way around the need for the global in this scenerio. After the installation process is complete, we can just variable_get() to find out what profile is active - that's how system.module did it until now.

But *before* the install, when htis code runs, we don't even have database access to call variable_set(). The name of the current profile (and thus the directory name we should be scanning) is stored in the global. In an earlier version of the patch I tried passing $profile_name into the function directly, but it's called from many locations in core, most of which need to work properly in the pre-install state. Passing it around instead of using the global would require 'punching' through several layers of includes and function calls, tacking an optional param onto the end of each one, for this single special case.

Long-term, this kind of situation is what chx's http://drupal.org/node/71113 patch would help solve. We may want to look into that to avoid sprinkling 'check for a global, then check the variables' logic throughout core.

eaton’s picture

Status: Needs review » Reviewed & tested by the community

Dries commented on IRC that he'd greenlight it if there were no clean solution for the global at this point. The bulk of this patch is moving the function to common.inc; the other two changes are pretty minor.

In that light, I'm RTBC'ing.

Dries’s picture

Status: Reviewed & tested by the community » Needs work

But the first thing we do is ask the user his database information? So in theory, we should be able to setup a database connection ... not?

(If not, please add some additional code comments to the function. Much of the knowledge you shared in the issue tracker is not documented in the code. Don't overdo it, but just explain why we do it the Ugly Way.)

eaton’s picture

Status: Needs work » Needs review
FileSize
8.81 KB

But the first thing we do is ask the user his database information? So in theory, we should be able to setup a database connection ... not?

Nope. We're in DRUPAL_BOOTSTRAP_CONFIGURATION mode when we hit this code. Absolutely nothing is installed, we're just *ensuring that the things the profile requires* are there *to* be installed.

(If not, please add some additional code comments to the function. Much of the knowledge you shared in the issue tracker is not documented in the code. Don't overdo it, but just explain why we do it the Ugly Way.)

function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1) {
  global $profile;
  $config = conf_path();
  
  // When this function is called during Drupal's initial installation process,
  // the name of the profile that's about to be installed is stored in the global
  // $profile variable. At all other times, the standard Drupal systems variable
  // table contains the name of the current profile, and we can call variable_get()
  // to determine what one is active.

  if (!isset($profile)) {
    $profile = variable_get('install_profile', 'default');
  }
asimmonds’s picture

FileSize
9.48 KB

Missed a system_listing() in themes/engines/phptemplate/phptemplate.engine

Patch updated with this change.

asimmonds’s picture

I've tested the functionality of this patch with some contrib modules spread across:
/modules
/profiles/$profile/modules
/sites/all/modules
/sites/$site/modules

With them listed in the .profile, have found no problems during the installation process.

Also duplicated some modules across the modules directories to test module prioritisation, which appears
to be working correctly.

Dries’s picture

Status: Needs review » Fixed

Committed to CVS HEAD. Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)