Some modules don't just depend on other modules, but also need to have a higher weight to be sure they can override those other modules. I propose a new property for info files to tell Drupal to give a module a higher weight than the modules defined with this new property.

name = Foo
description = "Bar."
core = 6.x
dependencies[] = taxonomy
dependencies[] = comment
weight[] = taxonomy

weight would be the new property. In this case module Foo should get a higher weight than taxonomy.module.

Comments

dave reid’s picture

As dicussed in #drupal, this would probably better implemented with using #253569: DX: Add hook_modules to act on other module status changes. If your module needs to set a weight higher or lower an a module, your module should implement:

function mymodule_install() {
  if (module_exists('devel')) {
    $devel_weight = db_result(db_query("SELECT weight FROM {system} WHERE name = '%s'", $module));
    db_query("UPDATE {system} SET weight = %d WHERE name = 'mymodule'", $devel_weight + 1);
  }
}

function mymodule_hook_install($module) {
  if ($module == 'devel') {
    $devel_weight = db_result(db_query("SELECT weight FROM {system} WHERE name = '%s'", $module));
    db_query("UPDATE {system} SET weight = %d WHERE name = 'mymodule'", $devel_weight + 1);
  }
}

Yes it's a little bit more work on the part of the module maintainer, but this solution is easier to implement into core. You can also end up with possible weight conflicts and having to reorder all the weights of the system table.

This is an interesting proposal and I'll look into it.

xano’s picture

I came up with this version before dinner. It doesn't apply anymore because it doesn't take conflicting weights into account, but I didn't want to keep it from you.

name = Foo
description = "Bar."
core = 6.x
dependencies[] = taxonomy
dependencies[] = comment
weight_higher[] = *
weight_lower[] = taxonomy

This would give foo.module a weight higher than any other module's, but lower than taxonomy's.

dave reid’s picture

Status: Active » Closed (duplicate)

Marking as a duplicate of #127641: Module weight in .info