Backport of #2855026: Installation profiles do not support project:module format for dependencies to Drupal 7.


In #2205271: Project namespace for dependencies support was added to allow modules to list dependencies by prefixing their names with their project name, thus solving the age-old problem of module names and project names being different (*cough* CCK *cough*). This API improvement was included in v7.40.

In #2844504: Testbot failing for Metatag-D7 =) it was identified that some of Metatag's tests were failing because the testci system was unable to download certain dependencies, specifically one submodule depending upon another submodule would fail if the dependency was listed in the old [module] syntax, it had to be listed in the newer [project:module] syntax.

It was reported in #2853699: Out-of-date dependency processing in panopoly_core by asacolips that this conflicts with installation profiles, which do not support the [project:module] syntax.
https://www.drupal.org/files/issues/drupal-n2905520-3.patch
A simple example is the following:

  • Download the latest Panopoly distribution release.
  • Set it up somewhere so it can be installed.
  • Download Metatag into the directory structure somewhere, e.g. sites/all/modules.
  • Edit the panopoly.info file to list Metatag as a dependency, e.g.:
    diff --git a/panopoly.info b/panopoly.info
    index 2ee445e..2752de7 100644
    --- a/panopoly.info
    +++ b/panopoly.info
    @@ -21,6 +21,8 @@ dependencies[] = file
     dependencies[] = dblog
     dependencies[] = update
     
    +dependencies[] = metatag
    +
     ; Panopoly Foundation
     dependencies[] = panopoly_core
     dependencies[] = panopoly_images
    
  • Hook up the codebase to the local web server and try to run the installer.
  • The following requirements error will be reported:

    Required modules - Required modules not found.
    The following modules are required but were not found. Move them into the appropriate modules subdirectory, such as sites/all/modules. Missing modules: Drupal:system, Ctools:ctools, Token:token

  • Further, if the dependency line in panopoly.info is changed to "dependencies[] = metatag:metatag" then the error becomes the following:

    Required modules - Required modules not found.
    The following modules are required but were not found. Move them into the appropriate modules subdirectory, such as sites/all/modules. Missing modules: Metatag:metatag

It seems like the dependency logic does not properly handle the [project:module] logic for modules available in the current codebase.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DamienMcKenna created an issue. See original summary.

DamienMcKenna’s picture

Version: 8.5.x-dev » 7.x-dev
DamienMcKenna’s picture

Status: Needs review » Needs work

The last submitted patch, 3: drupal-n2905520-3.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

torotil’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
808 bytes

The same patch again with a fixed typo.

Status: Needs review » Needs work

The last submitted patch, 5: drupal-namespaced-profile-dependencies-2905520-5.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

torotil’s picture

Status: Needs work » Needs review
FileSize
810 bytes

… and fix another set of typos in the original patch.

torotil’s picture

For me the test case (and the problem) is a bit different than in the original ticket description. Having modules with project:module dependencies in as dependency of the installation profile works fine. The problem is having project:module dependencies in the installation profile itself.

In my case I’m always starting with the minimal profile and I have metatag-7.x-1.21 (a module with project:module dependencies) plus its dependencies in the drupal tree.

Without the patch

  1. Adding dependencies[] = metatag to minimal.info works.
  2. Adding dependencies[] = metatag (=7.x-1.21) to minimal.info fails.
  3. Adding dependencies[] = metatag:metatag to minimal.info fails.

With the patch

  1. Adding dependencies[] = metatag to minimal.info works.
  2. Adding dependencies[] = metatag (=7.x-1.21) to minimal.info works.
  3. Adding dependencies[] = metatag:metatag to minimal.info works.

It seems that only the direct dependencies of the profile are a problem.

torotil’s picture

Note that with Panopoly it also becomes a problem if direct dependencies of the profile use new-style dependencies. Thus the OP. It’s due to this code in Panopoly:

/**
 * Task handler to load our install profile and enhance the dependency information
 */
function panopoly_core_install_load_profile(&$install_state) {

  // Loading the install profile normally
  install_load_profile($install_state);

  // Include any dependencies that we might have missed...
  $dependencies = $install_state['profile_info']['dependencies'];
  foreach ($dependencies as $module) {
    $module_info = drupal_parse_info_file(drupal_get_path('module', $module) . '/' . $module . '.info');
    if (!empty($module_info['dependencies'])) {
      foreach ($module_info['dependencies'] as $dependency) {
        $parts = explode(' (', $dependency, 2);
        $dependencies[] = array_shift($parts);
      }
    }
  }
  $install_state['profile_info']['dependencies'] = array_unique($dependencies);
}

Also the current patch does not actually make the installation profiles support complex dependencies it just removes them before they are being interpreted. The actual fix would perhaps be in #820054: Add support for recommends[] and fix install profile dependency special casing. In the meanwhile this is a viable workaround.

eelkeblok’s picture

Title: Installation profiles do not support project:module format for dependencies Primary tabs View(active tab) Edit View (backport to D7) » Installation profiles do not support project:module format for dependencies (backport to D7)

I think this is what the title is supposed to be? Correct me if I'm wrong.