In 5.x the --no-core option checks if $extension->info['package'] == 'Core' but in Drupal 6 this could be either 'Core - required' or 'Core - optional'.

This worked correctly in drush 4.x because the test checked for $extension->info['version'] == VERSION, an approach which had its own problems but which worked consistently in Drupal 6 & 7.

I noticed this while testing the drush extension project_status, which was working with drush 4.x for both D6 & D7 sites, but had problems with drush 5.x.

Comments

mvc’s picture

Status:Active» Needs review
StatusFileSize
new1.19 KB
mvc’s picture

from #drush:

11:57 jonhattan| mvc, check for $extension->info['project'] == 'drupal'
11:58 jonhattan| it should work for both 6 and 7
11:58 jonhattan| also must be checked for drupal 8
11:59 jonhattan| mvc, other way is $extension->info['version'] == VERSION
12:00 jonhattan| as in drush_get_projects()

greg.1.anderson’s picture

Started to look at this the other day, but could not test D8 due to #1846058: Invalid arguments on DrupalKernel __construct(), which is now fixed. Jonhattan's advice looks good.

mvc’s picture

StatusFileSize
new787 bytes

I've redone my patch to check for $extension->info['project']. This works in Drupal 6, 7, and 8. I didn't use version because I think that would give unexpected results when using a contributed module whose version number happens to be the same as the version number of Drupal core.

While testing I noticed that Drupal 6 themes do not set a package, and so are listed as 'Other' (actually, as t('Other')). My first approach didn't handle this, but the new patch should work with Drupal 6 themes and modules.

The latest code in the 7.x-5.x branch (16c782de) blows up on the current Drupal 8 ("PHP Fatal error: Call to undefined function conf_path() in /home/mvc/drush-development/drush/includes/bootstrap.inc on line 784") but I see that the .info files for core modules and themes look the same as in Drupal 7 so I expect this to work once whatever other bug that is gets fixed.

Thanks for the feedback, jonhattan and greg.1.anderson.

greg.1.anderson’s picture

Regarding testing the version (as Drush formerly did), that never caused a conflict with contrib modules in the past because contrib version numbers follow a different format than core version numbers (e.g. "7.17" for core, and "7.x-1.0" for contrib). However, I think that testing for project == drupal is still best. Code in #4 looks good, but I have not tested it yet.

greg.1.anderson’s picture

Status:Needs review» Active

Worked great for me on D6 and D7, so committed #4. I didn't test D8 because I wasn't able to download it due to an invalid checksum. Then I remembered I had a running copy of D8 still (amazing the clarity that 'git push' can bring sometimes), so I tested there and discovered that D8 does not have a 'project' item for Core in D8.

So, I think we need to test 'package' == 'Core' for D7+, and the test from #4 for D6.

greg.1.anderson’s picture

Status:Active» Fixed

Pushed one more modification to make --core and --no-core work on D6, D7 and D8.

Status:Fixed» Closed (fixed)

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

drzraf’s picture

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

using --no-core: Undefined index: project pm.drush.inc:670
using --core: Undefined index: project pm.drush.inc:677
[ but notice is hidden using --pipe ]
Using latest 7.x-5.x + Drupal 6.28

Sample $extension:

<?php
class stdClass#58 (10) {
 
public $filename =>
 
string(28) "modules/openid/openid.module"
 
public $basename =>
 
string(13) "openid.module"
 
public $name =>
 
string(6) "openid"
 
public $type =>
 
string(6) "module"
 
public $status =>
 
string(1) "0"
 
public $throttle =>
 
string(1) "0"
 
public $schema_version =>
 
string(2) "-1"
 
public $old_filename =>
 
string(28) "modules/openid/openid.module"
 
public $info =>
  array(
8) {
   
'name' =>
   
string(6) "OpenID"
    'description'
=>
   
string(48) "Allows users to log into your site using OpenID."
    'version'
=>
   
string(4) "6.28"
    'package'
=>
   
string(15) "Core - optional"
    'core'
=>
   
string(3) "6.x"
    'dependencies'
=>
    array(
0) {
    }
   
'dependents' =>
    array(
0) {
    }
   
'php' =>
   
string(5) "4.3.5"
 
}
  public
$label =>
 
string(15) "OpenID (openid)"
}
?>
drzraf’s picture

Status:Active» Needs review
StatusFileSize
new811 bytes

this works for both D6 and D7

greg.1.anderson’s picture

Version:7.x-5.x-dev» 8.x-6.x-dev

Thank you for working on this. Could you re-roll against Drush-8.x-6.x and test on Drupal 8 as well?

drzraf’s picture

please excuse me but I'm really not willing to spend time into D8.

greg.1.anderson’s picture

Status:Needs review» Fixed

Actually, the code already in 8.x-6.x is already working. Backported what was there to the 7.x-5.x branch.

drzraf’s picture

Status:Fixed» Active
StatusFileSize
new1.18 KB

I'm sorry, but this is not fixed in D6:

drush pml --core
Core - required  User (user)  Module  Enabled  6.20
$ drush pml |grep Core
Core - optional      Aggregator (aggregator)                                        Module  Not installed  6.28         
Core - optional      Blog (blog)                                                    Module  Not installed  6.28         
Core - optional      Blog API (blogapi)                                             Module  Not installed  6.28         
Core - optional      Book (book)                                                    Module  Enabled        6.28         
Core - optional      Color (color)                                                  Module  Disabled       6.28         
Core - optional      Comment (comment)                                              Module  Enabled        6.28         
Core - optional      Contact (contact)                                              Module  Enabled        6.28         
Core - optional      Content translation (translation)                              Module  Enabled        6.28         
Core - optional      Database logging (dblog)                                       Module  Enabled        6.28         
Core - optional      Forum (forum)                                                  Module  Disabled       6.28         
Core - optional      Help (help)                                                    Module  Enabled        6.28         
Core - optional      Locale (locale)                                                Module  Enabled        6.28         
Core - optional      Menu (menu)                                                    Module  Enabled        6.28         
Core - optional      OpenID (openid)                                                Module  Not installed  6.28         
Core - optional      Path (path)                                                    Module  Enabled        6.28         
Core - optional      PHP filter (php)                                               Module  Enabled        6.28         
Core - optional      Ping (ping)                                                    Module  Not installed  6.28         
Core - optional      Poll (poll)                                                    Module  Not installed  6.28         
Core - optional      Profile (profile)                                              Module  Not installed  6.28         
Core - optional      Search (search)                                                Module  Not installed  6.28         
Core - optional      Statistics (statistics)                                        Module  Enabled        6.28         
Core - optional      Syslog (syslog)                                                Module  Enabled        6.28         
Core - optional      Taxonomy (taxonomy)                                            Module  Enabled        6.28         
Core - optional      Throttle (throttle)                                            Module  Not installed  6.28         
Core - optional      Tracker (tracker)                                              Module  Enabled        6.28         
Core - optional      Trigger (trigger)                                              Module  Not installed  6.28         
Core - optional      Update status (update)                                         Module  Enabled        6.28         
Core - optional      Upload (upload)                                                Module  Enabled        6.28         
Core - required      Block (block)                                                  Module  Enabled        6.28         
Core - required      Filter (filter)                                                Module  Enabled        6.28         
Core - required      Node (node)                                                    Module  Enabled        6.28         
Core - required      System (system)                                                Module  Enabled        6.28         
Core - required      User (user)                                                    Module  Enabled        6.20

This is a 6.20 installation + a patch applied to 6.28.
Please note that the patch provided in comment 10 used strpos(): rerolled

greg.1.anderson’s picture

Status:Active» Postponed (maintainer needs more info)

That's not the result I am getting with 8.x-6.x and 7.x-5.x using recent, clean versions of Drupal 6 and Drupal 7.

I am not happy with the strpos solution; package can be anything, and there is no saying that someone might not use the word "Core" to mean something other than "Drupal Core". It could match "Corel Reef" or "Core Beliefs". If the existing code really does not work, maybe we can break down and explicitly test for "Core - optional" and "Core - required" iff Drupal major version < 7.

If you would like to continue here, please test on a clean install of the most recent Drupal 6 release. Include a test that fails on Drush 8.x-6.x or 7.x-5.x head, and a patch that fixes the failure. If this only fails with older versions of Drush 6.x, we can discuss with other maintainers how far back we need to support.

mvc’s picture

i can't reproduce this either. using both 8.x-6.x and 7.x-5.x i get the same output:

$ ~/drush-8.x-6.x/drush pml --core
Package          Name                               Type    Status         Version
Core - optional  Aggregator (aggregator)            Module  Disabled       6.26   
Core - optional  Blog (blog)                        Module  Not installed  6.26   
Core - optional  Blog API (blogapi)                 Module  Disabled       6.26   
Core - optional  Book (book)                        Module  Enabled        6.26   
Core - optional  Color (color)                      Module  Disabled       6.26   
Core - optional  Comment (comment)                  Module  Enabled        6.26   
Core - optional  Contact (contact)                  Module  Not installed  6.26   
Core - optional  Content translation (translation)  Module  Enabled        6.26   
Core - optional  Database logging (dblog)           Module  Enabled        6.26   
Core - optional  Forum (forum)                      Module  Enabled        6.26   
Core - optional  Help (help)                        Module  Enabled        6.26   
Core - optional  Locale (locale)                    Module  Enabled        6.26   
Core - optional  Menu (menu)                        Module  Enabled        6.26   
Core - optional  OpenID (openid)                    Module  Disabled       6.26   
Core - optional  Path (path)                        Module  Enabled        6.26   
Core - optional  PHP filter (php)                   Module  Enabled        6.26   
Core - optional  Ping (ping)                        Module  Not installed  6.26   
Core - optional  Poll (poll)                        Module  Not installed  6.26   
Core - optional  Profile (profile)                  Module  Disabled       6.26   
Core - optional  Search (search)                    Module  Enabled        6.26   
Core - optional  Statistics (statistics)            Module  Enabled        6.26   
Core - optional  Syslog (syslog)                    Module  Not installed  6.26   
Core - optional  Taxonomy (taxonomy)                Module  Enabled        6.26   
Core - optional  Throttle (throttle)                Module  Not installed  6.26   
Core - optional  Tracker (tracker)                  Module  Not installed  6.26   
Core - optional  Trigger (trigger)                  Module  Enabled        6.26   
Core - optional  Update status (update)             Module  Disabled       6.26   
Core - optional  Upload (upload)                    Module  Enabled        6.26   
Core - required  Block (block)                      Module  Enabled        6.26   
Core - required  Filter (filter)                    Module  Enabled        6.26   
Core - required  Node (node)                        Module  Enabled        6.26   
Core - required  System (system)                    Module  Enabled        6.26   
Core - required  User (user)                        Module  Enabled        6.26   
Other            Bluemarine (bluemarine)            Theme   Disabled       6.26   
Other            Chameleon (chameleon)              Theme   Disabled       6.26   
Other            Garland (garland)                  Theme   Disabled       6.26   
Other            Marvin (marvin)                    Theme   Disabled       6.26   
Other            Minnelli (minnelli)                Theme   Disabled       6.26   
Other            Pushbutton (pushbutton)            Theme   Disabled       6.26   
greg.1.anderson’s picture

Status:Postponed (maintainer needs more info)» Closed (won't fix)
Issue tags:+needs migration

This issue was marked closed (won't fix) because Drush has moved to Github.

If desired, you may copy this bug to our Github project and then post a link here to the new issue. Please also change the status of this issue to closed (duplicate).

Please ask support questions on Drupal Answers.

greg.1.anderson’s picture

Issue summary:View changes

better description