Currently, the PM extension for drupal requires Drupal 6.

However, The Code below adds in checking for Drupal 5. Which makes no sense to me. It later calls functions that do not return the right datatype in drupal core (i.e. arrays vs NULL). In this case, the non-compatible function is pm_dependencies().

Please change this code so people still on Drupal 5 can use this wonderful piece of work. It's Great!

function pm_module_manage($modules = array(), $enable = TRUE) {
  if (function_exists('module_load_include')) {
    module_load_include('inc', 'system', 'system.admin');
  }
  else {
    // Drupal5 only.
    require_once('./'. drupal_get_path('module', 'system') .'/system.module');
  }
  $form = system_modules();
  if (empty($modules)) {
    pm_module_status($form);
  }
  else {
    $requested_modules = $modules;
    if ($enable) {
      pm_dependencies($modules, $form);
...
}

Comments

awesomepossum’s picture

StatusFileSize
new1.61 KB

I have Created a patch file for making all of the PM commands backwards compatible with drupal 5. It was a simple patch (maybe too easy?), deleting the core reqs and adding a check for non-array data types. Doing a basic test of this, all seemed fine inlcuding statusmodules, enable and disable. The Patch is attached.

awesomepossum’s picture

Priority: Normal » Critical

Would someone please reply to this post? I would like to see this patch added if at all possible. If the patch is not sufficient I would like direction on what changes need to be made in order for the enhancements to be made.

owen barton’s picture

Status: Active » Reviewed & tested by the community

This looks great thanks!

moshe weitzman’s picture

Oh no, another great nick has fallen. Bye Grugnog2. Owen is has a nice ring tho.

owen barton’s picture

Status: Reviewed & tested by the community » Fixed

Committed - thanks!

moshe weitzman’s picture

Category: feature » bug
Status: Fixed » Active

This broke enable command in D7. In the log below, devel is indeed available:

)
Module devel was not found and will not be enabled.                                            [error]
There were no modules that could be enabled.                                                   [ok]
Warning: Invalid argument supplied for foreach() in pm_module_manage() (line 219 of            [warning]
/Users/mw/contributions/modules/drush/commands/pm/pm.drush.inc).
Warning: array_search(): Wrong datatype for second argument in pm_dependencies() (line 308 of  [warning]
/Users/mw/contributions/modules/drush/commands/pm/pm.drush.inc).
An error occurred at function : drush_pm_enable                                                [error]
awesomepossum’s picture

Should I submit another patch to try to fix this in Drupal 7? Not sure what the proper procedure is here.

owen barton’s picture

If it looks like a reasonably easy fix then that would be great - however if the data format has changed a lot in Drupal 7 we should just add back a core => array(5,6) for now (and ideally patch Drupal 7 core so we have a very simple way to enable and disable modules in the future!).

moshe weitzman’s picture

Yes, please attach a new patch here. Alternatively, mark this issue fixed and add a new issue. Both are legitimate.

moshe weitzman’s picture

I looked into this. The patch is non trivial for D7. I agree with Owen that we should add back array(5,6) as supported versions for various pm commands. I'd love it awesomepossum could actually make it work on 7, but I'll take an immediate quick fix for Drush2.

owen barton’s picture

Going to see if I can clean this up a bit

owen barton’s picture

Status: Active » Fixed

Enable/disable/statusmodules now all work on Drupal 5, 6 and 7 now, and are quite a bit cleaner (I was able to remove the $form hackery).

moshe weitzman’s picture

Wow, great work Owen. many thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.