I discovered this by checking out views-HEAD from cvs and then running drush en views on a Drupal 7 site. Views-HEAD is still the D6 version but Drush went ahead and enabled the module anyway.

Patch attached that re-uses function from common/update.inc to check the compatibility on the module (or theme).

The patch exits the enable process with the message "!name is incompatible with the Drupal version."

Comments

moshe weitzman’s picture

We need to look closely to see if there are other checks we are missing. I recall that we check for hook_requirements so I am surprised we missed this one.

alexpott’s picture

I think this one might be missing because in the submit function for the enable modules form it doesn't actually check core compatibility. It's already checked for it when displaying the form and disabled the checkboxes for incompatible modules.

alexpott’s picture

Ignore the patches above. They don't work in all versions of Drupal. Currently rolling a patch that does.

alexpott’s picture

That worked out quicker than I expected...

The new patch uses drush_include_engine('drupal', 'update', drush_drupal_major_version()); to allow the enable command to check a project's (module or theme) compatibility with Drupal.

The only possible snag is that Drush's update_7.inc now has to always include Drupal's update.inc. This is because Drush update_6.inc has the update_check_incompatibility() function copied from update.php in it but update_7.inc does not.

greg.1.anderson’s picture

Status: Active » Needs review

Code looks good, but have not tried it.

jonhattan’s picture

Status: Needs review » Fixed

Commited with a change. drush_include_engine('drupal', 'update') --it will guess the core version.

for the record: this fix also check php incompatibility.

Status: Fixed » Closed (fixed)

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

msonnabaum’s picture

Version: » All-versions-4.x-dev
Assigned: Unassigned » jonhattan
Status: Closed (fixed) » Patch (to be ported)

I had to bring this into 4.x to backport #1105642. It looks safe to me, but I'd like to get a confirmation just to make sure I'm not missing something.

jonhattan’s picture

Version: All-versions-4.x-dev »
Category: bug » task
Status: Patch (to be ported) » Needs review
StatusFileSize
new1.97 KB

Yeah it looks safe but now that I revisit the code, it also looks a considerable performance hit.

From http://api.drupal.org/api/drupal/includes--update.inc/function/update_ch...

    $themes = system_rebuild_theme_data();
    $modules = system_rebuild_module_data();

In a simple test just comparing drush -d php-eval "print 1;" to drush -d php-eval "system_rebuild_module_data();" the difference is slightly more than 1 second.

Patch attached that brings the needed code from drupal to drush.

twod’s picture

#9 seems to work for me.
I was getting errors that update_check_incompatibility() was undefined (guess it failed to get included for some reason) when used with D7. I didn't bother looking deeper into the issue and just applied this patch instead, problem solved.
Had to apply one chunk manually, (the one removing the old include call in the enable command) but I'm not sure I applied it to the latest version.

EDIT: I uninstalled Drush 7.x-4.5 since it was giving me more undefined-function-errors when removing modules as well.
Installed All-versions-5.x-dev and applied patch to it instead (just some offset and fuzz, no errors). All ok now!

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Sounds like this is RTBC. I will let jonhattan commit to master and 4.x

jonhattan’s picture

Status: Reviewed & tested by the community » Fixed

done.

Status: Fixed » Closed (fixed)

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

a8w4’s picture

Version: » 7.x-4.6
Category: task » bug
Status: Closed (fixed) » Active

drush en & drush dis throw always an error "$module is incompatible with the Drupal version." under drupal 5.x (5.23 to be exact) even if they are drupal 5.x versions - I downgraded to Drush 7.x-4.5 - there the false error is not present.

greg.1.anderson’s picture

Version: 7.x-4.6 »
Status: Active » Closed (fixed)

Drush 5.x does not support Drupal 5.x; you must use Drush-4.x with Drupal 5.

I'm surprised that Drush-5.x is not telling you that Drupal-5.x is not supported; I imagine that if you used the latest code from master it would. In any event, if there are problems with this, it should be reported in a separate issue.