Hi guys.

I just bumped into error mentioned above, here is complete debug data:

% drush dis views -d
Drush bootstrap phase : _drush_bootstrap_drupal_root() [0.03 sec, 2.67 MB]	[bootstrap]
Initialized Drupal 6.16 root directory at /www/sites/www.example.com [0.04 sec, 3.42 MB]	[notice]
Drush bootstrap phase : _drush_bootstrap_drupal_site() [0.05 sec, 3.46 MB]	[bootstrap]
Initialized Drupal site default at sites/default [0.06 sec, 3.56 MB]	[notice]
Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [0.07 sec, 3.59 MB]	[bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_database() [0.08 sec, 3.6 MB]	[bootstrap]
Successfully connected to the Drupal database. [0.08 sec, 3.6 MB]	[bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_full() [0.09 sec, 3.82 MB]	[bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_login() [0.24 sec, 17.07 MB]	[bootstrap]
Found command: pm-disable (commandfile=pm) [0.25 sec, 17.25 MB]	[bootstrap]
Including version specific file : /home/users/mm/opt/drush/commands/core/drupal/environment_6.inc [0.25 sec, 17.26 MB]	[notice]
The following projects will be disabled: views, views_export, views_ui
Do you really want to continue? (y/n): y
Including version specific file : /home/users/mm/opt/drush/commands/core/drupal/environment_6.inc [9.01 sec, 24.4 MB]	[notice]
WD php: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '_export, 'views'_ui)' at lin1	[error]
query: SELECT name, status FROM system WHERE name IN ('views', 'views'_export, 'views'_ui) in /home/users/mm/opt/drush/includes/drush.inc on line 349. [9.01 sec, 24.41 MB]
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '_export, 'views'_ui)' at line 1	[error]
query: SELECT name, status FROM system WHERE name IN ('views', 'views'_export, 'views'_ui) in
/home/users/mm/opt/drush/includes/drush.inc on line 349. [9.01 sec, 24.18 MB]
An error occurred at function : drush_pm_disable [9.01 sec, 24.18 MB]	[error]
Command dispatch complete [9.01 sec, 24.17 MB]	[notice]
 Timer  Cum (sec)  Count  Avg (msec)
 page   8.941      1      8940.57
Peak memory usage was 25.63 MB [9.01 sec, 24.17 MB]	[memory]

This also occur when you run drush en views views_export views_ui command.

Modules are actually disabled / enabled, but you still get this ugly error. :(

CommentFileSizeAuthor
#10 764800.patch1.2 KBjonhattan
#3 764800.patch695 bytesjonhattan

Comments

xurizaemon’s picture

More debug output from enabling a (custom, features-generated) module with dependencies on several other contrib modules today.

Complains about detected recursion in array_merge_recursive() (it appears this aspect may be unrelated to underscores, as I see this when enabling modules without underscores).

Then produces SQL of the form SELECT name, status FROM main_system WHERE name IN ('aug_features', 'activitystream', 'emvideo', 'features', 'imagecache', 'imagefield', 'kml', 'location_cck', 'views_coda', 'viewscarousel', 'emfield', 'emvideo'0, 'emvideo'1, 'emvideo'2, 'emvideo'3)

Full output:

The following projects will be enabled: aug_features, activitystream, emvideo, features, imagecache, imagefield, kml, location_cck, views_coda, viewscarousel, emfield, imageapi, filefield, location, jcarousel
Do you really want to continue? (y/n): y
WD php: array_merge_recursive(): recursion detected in /Users/chris/Sites/greens_au/includes/module.inc on line 485.                                                                                  [error]
WD actions: 3 orphaned actions (og_remove_groups_action, og_make_public_action, og_make_private_action) exist in the actions table. Remove orphaned actions                                           [warning]
WD php: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0, 'emvideo'1, 'emvideo'2, 'emvideo'3)' at line 1      [error]
query: SELECT name, status FROM main_system WHERE name IN ('aug_features', 'activitystream', 'emvideo', 'features', 'imagecache', 'imagefield', 'kml', 'location_cck', 'views_coda', 'viewscarousel',
'emfield', 'emvideo'0, 'emvideo'1, 'emvideo'2, 'emvideo'3) in /Users/chris/Documents/Clients/Drupal/DRUPAL-HEAD/drush-HEAD/includes/drush.inc on line 349.
array_merge_recursive(): recursion detected in /Users/chris/Sites/greens_au/includes/module.inc on line 485.                                                                                          [warning]
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0, 'emvideo'1, 'emvideo'2,            [error]
'emvideo'3)' at line 1
query: SELECT name, status FROM main_system WHERE name IN ('aug_features', 'activitystream', 'emvideo', 'features', 'imagecache',
'imagefield', 'kml', 'location_cck', 'views_coda', 'viewscarousel', 'emfield', 'emvideo'0, 'emvideo'1,
'emvideo'2, 'emvideo'3) in /Users/chris/Documents/Clients/Drupal/DRUPAL-HEAD/drush-HEAD/includes/drush.inc on line 349.
An error occurred at function : drush_pm_enable

I am in a good position to replicate this issue if further information is required.

@mariomaric, what led you to the conclusion that underscores are part of the issue here? (The above example appears to support this assertion.)

izkreny’s picture

Title: You have an error in your SQL syntax when disabling / enabling modules with underscore in name » You have an error in your SQL syntax when disabling / enabling modules with dependencies

Oops, sorry, wrong assumption.

As I can see from now (after little bit more testing and yours feedback), it is related to enabling / disabling modules that has dependencies on other modules (so I changed issue title).

I can also confirm that this problem is not present in 6.x-3.0-rc1, it occurs in 6.x-3.0-rc2 version (and above).

jonhattan’s picture

Title: You have an error in your SQL syntax when disabling / enabling modules with dependencies » SQL error when disabling / enabling projects with names that are a prefix of others (ie: views, views_ui)
Status: Active » Needs review
StatusFileSize
new695 bytes

I've traced down the bug to happen when the final list of projects to en/dis contain projects whose name is a prefix of another project(s) in the list. That is drush pm-enable views views_ui assuming both modules are disabled (or viceversa).

The bug can be reproduced on its basis with:

drush php-eval "drush_db_select('system', array('name','status'), 'name IN (:projects)', array(':projects' => array('views' => 'views', 'views_ui' => 'views_ui', 'views_export' => 'views_export')));"

It happens because the $args passed from pm_enable/disable to drush_db_select() has a form with key = value:

Array
(
    [:projects] => Array
        (
            [views] => views
            [views_ui] => views_ui
            [views_export] => views_export
        )
)

Attached is a fix based on forcing to use always numeric keys.

moshe weitzman’s picture

nice research ... could we rephrase '# grant $i is not a prefix of $value'. not sure what that means.

jonhattan’s picture

In fact the comment is wrong.

New comment:

      // $data can't have keys that are a prefix of other keys to
      // prevent a corrupted result in the below calls to str_replace().
      // To avoid this we will use a indexed array of the values of $data.

I'm not good enough with english. Alter it if you consider so.

jonhattan’s picture

In fact the comment is wrong.

New comment:

      // $data can't have keys that are a prefix of other keys to
      // prevent a corrupted result in the below calls to str_replace().
      // To avoid this we will use a indexed array of the values of $data.

I'm not good enough with english. Alter it if you consider so.

moshe weitzman’s picture

Status: Needs review » Fixed

comitted. thx.

Status: Fixed » Closed (fixed)

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

guidot’s picture

Status: Closed (fixed) » Active

I still get these errors with latest HEAD:

The following projects will be enabled: content_profile, journal, imagecache_profiles, translation_helpers, translation_overview, logintoboggan, masquerade, realname, r4032login, security_review, submitted_by
Do you really want to continue? (y/n): y
WD php: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server     [error]
version for the right syntax to use near '0)' at line 1
query: SELECT name, status FROM system WHERE name IN ('content_profile', 'journal',
'imagecache_profiles', 'translation_helpers', 'translation_overview', 'logintoboggan', 'masquerade',
'realname', 'r4032login', 'security_review', 'journal'0) in /usr/local/drush/includes/drush.inc on line
352.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for [error]
the right syntax to use near '0)' at line 1
query: SELECT name, status FROM system WHERE name IN ('content_profile', 'journal',
'imagecache_profiles', 'translation_helpers', 'translation_overview',
'logintoboggan', 'masquerade', 'realname', 'r4032login',
'security_review', 'journal'0) in /usr/local/drush/includes/drush.inc on line 352.
An error occurred at function : drush_pm_enable                                                          [error]

In this case the list does not contain projects whose name is a prefix of another project in that list.

jonhattan’s picture

Priority: Minor » Normal
Status: Active » Needs review
StatusFileSize
new1.2 KB

It happens when the number of projects is greater than 10.

Attached patch enforces unique keys by zero-padding the keys on the left so they will be 00..09,10 instead of 0..9,10.

guidot’s picture

Status: Needs review » Reviewed & tested by the community

Patch in #10 works as advertised with more than 10 projects. Thanks jonhattan!

moshe weitzman’s picture

Status: Reviewed & tested by the community » Fixed

committed. thanks.

Status: Fixed » Closed (fixed)

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