Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.4.9, 4.5.3
-
Fix Version/s: 4.5.5
-
Component/s: Drupal Integration Modules
-
Labels:None
-
Documentation Required?:None
Description
Currently most of the drush civicrm_sql* functions don't work correctly for drush versions >= 6, in a way that they don't operate on the CiviCRM database, but on the Drupal database.
Only drush sql_connect was fixed for drush versions >= 6 by CRM-14359, but unfortunately that fix broke the drush 5 support.
The problem is that drush 5 and drush 6 use a different naming pattern for hooks when using a custom callback.
To better explain the problem, see the example below:
In drush 5, the hooks are based on the callback name, as in drush 6, they are based on the command name
drush5 civicrm-sql-query --show-invoke 2>&1 "" | grep "drush_civicrm" | egrep -v "(connect|member)" | cut -d\ -f1
drush_civicrm_sqlquery_pre_validate
drush_civicrm_sqlquery_validate
drush_civicrm_pre_civicrm_sqlquery
drush_civicrm_sqlquery
drush_civicrm_post_civicrm_sqlquery
drush_civicrm_pre_civicrm_sqlquery_rollback
drush_civicrm_sqlquery_rollback
drush_civicrm_post_civicrm_sqlquery_rollback
drush6 civicrm-sql-query --show-invoke 2>&1 "" | grep "drush_civicrm" | egrep -v "(connect|member)" | cut -d\ -f1
drush_civicrm_sql_query_pre_validate
drush_civicrm_sql_query_validate
drush_civicrm_pre_civicrm_sql_query
drush_civicrm_sqlquery
drush_civicrm_post_civicrm_sql_query
drush_civicrm_sqlquery_rollback
drush_civicrm_post_civicrm_sql_query_rollback
The result is that the CiviCRM database is never used with drush 6, as the drush_civicrm_sql_*_validate function doesn't exist:
drush5 civicrm-sql-query "select count from civicrm_acl"
count
65
drush civicrm-sql-query "select count from civicrm_acl"
ERROR 1146 (42S02) at line 1: Table 'test_drupal.civicrm_acl' doesn't exist
Currently the validate hook is used to switch to the CiviCRM database, but I think it's a better idea to use the pre and post hooks as in CRM-14359.
I couldn't find any documentation on which versions of drush are officially supported by the Drupal module, so I fixed it for both versions.
Imho, I think it's a good idea to deprecate drush 5 support an remove it in a future release, as it isn't supported anymore.
The PR fixes the problem by supporting both the drush 5 and drush 6
Attachments
Issue Links
- is supplemented by
-
CRM-15429 Support Drush 7
- Done/Fixed