drush-ops / drush

Drush is a command-line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those who spend their working hours hacking away at the command prompt.
https://www.drush.org
2.33k stars 1.08k forks source link

Command specific option --target conflicts with core sql option #1905

Closed whikloj closed 8 years ago

whikloj commented 8 years ago

I apologize if this was answered, but I have not been able to locate a similar issue, bug, comment or request.

We have a bunch of drush commands that have worked under drush 5 and 6 but seems to die under drush 7 (I haven't tried drush 8).

The commands have an option named target and this seems to conflict with the option in the drush sql-connect.

See example drush command file here: https://github.com/Islandora/islandora_newspaper_batch/blob/7.x/islandora_newspaper_batch.drush.inc#L25

With drush 6.x-dev installed

vagrant@islandora:~$ drush -r /var/www/drupal -v --user=admin status
Initialized Drupal 7.39 root directory at /var/www/drupal                                                                                         [notice]
Initialized Drupal site default at sites/default                                                                                                  [notice]
Loading outputformat engine.                                                                                                                      [notice]
 Drupal version                  :  7.39                  
 Site URI                        :  http://default        
 Database driver                 :  mysql                 
 Database username               :  root                  
 Database name                   :  drupal7               
 Database                        :  Connected             
 Drupal bootstrap                :  Successful            
 Drupal user                     :  admin                 
 Default theme                   :  bartik                
 Administration theme            :  seven                 
 PHP executable                  :  /usr/bin/php          
 PHP configuration               :  /etc/php5/cli/php.ini 
 PHP OS                          :  Linux                 
 Drush version                   :  6.8-dev               
 Drush configuration             :                        
 Drush alias files               :                        
 Drupal root                     :  /var/www/drupal       
 Site path                       :  sites/default         
 File directory path             :  sites/default/files   
 Temporary file directory path   :  /tmp                  

Command dispatch complete                                                                                                                         [notice]
vagrant@islandora:~$ drush -r /var/www/drupal -v --user=admin islandora_newspaper_batch_preprocess --type=directory --target=/winnipeg_tribune/batch_1 --namespace=islandora --parent='islandora:21'
Initialized Drupal 7.39 root directory at /var/www/drupal                                                                                         [notice]
Initialized Drupal site default at sites/default                                                                                                  [notice]
Command dispatch complete                                                                                                                         [notice]
vagrant@islandora:~$ 

But with drush 7.x-dev installed

vagrant@islandora:~$ drush -r /var/www/drupal -v --user=admin status
Executing: mysql --defaults-extra-file=/tmp/drush_86PaGA --database=drupal7 --host=localhost --silent  < /tmp/drush_Kgtqz5
Executing: mysql --defaults-extra-file=/tmp/drush_83gRVA --database=drupal7 --host=localhost --silent  < /tmp/drush_KOf0N5
Loading outputformat engine.                                                                                                                      [notice]
 Drupal version                  :  7.39                                                 
 Site URI                        :  http://default                                       
 Database driver                 :  mysql                                                
 Database hostname               :  localhost                                            
 Database port                   :                                                       
 Database username               :  root                                                 
 Database name                   :  drupal7                                              
 Drupal bootstrap                :  Successful                                           
 Drupal user                     :  admin                                                
 Default theme                   :  bartik                                               
 Administration theme            :  seven                                                
 PHP executable                  :  /usr/bin/php                                         
 PHP configuration               :  /etc/php5/cli/php.ini                                
 PHP OS                          :  Linux                                                
 Drush script                    :  /home/vagrant/.composer/vendor/drush/drush/drush.php 
 Drush version                   :  7.2-dev                                              
 Drush temp directory            :  /tmp                                                 
 Drush configuration             :                                                       
 Drush alias files               :                                                       
 Install profile                 :  standard                                             
 Drupal root                     :  /var/www/drupal                                      
 Site path                       :  sites/default                                        
 File directory path             :  sites/default/files                                  
 Temporary file directory path   :  /tmp                                                 

Command dispatch complete                                                                                                                         [notice]
vagrant@islandora:~$ drush -r /var/www/drupal -v --user=admin islandora_newspaper_batch_preprocess --type=directory --target=/winnipeg_tribune/batch_1 --namespace=islandora --parent='islandora:21'
The drush command 'islandora_newspaper_batch_preprocess' could not be found.  Run `drush cache-clear drush` to clear the commandfile cache if  [error]
you have installed new extensions.
Drush was not able to start (bootstrap) the Drupal database.                                                                                   [error]
Hint: This may occur when Drush is trying to:
 * bootstrap a site that has not been installed or does not have a configured database. In this case you can select another site with a working
database setup by specifying the URI to use with the --uri parameter on the command line. See `drush topic docs-aliases` for details.
 * connect the database through a socket. The socket file may be wrong or the php-cli may have no access to it in a jailed shell. See
http://drupal.org/node/1428638 for details.

Drush was attempting to connect to: 
 Drupal version         :  7.39                                                 
 Site URI               :  http://default                                       
 PHP executable         :  /usr/bin/php                                         
 PHP configuration      :  /etc/php5/cli/php.ini                                
 PHP OS                 :  Linux                                                
 Drush script           :  /home/vagrant/.composer/vendor/drush/drush/drush.php 
 Drush version          :  7.2-dev                                              
 Drush temp directory   :  /tmp                                                 
 Drush configuration    :                                                       
 Drush alias files      :                                                       
 Drupal root            :  /var/www/drupal                                      
 Site path              :  sites/default                                        

vagrant@islandora:~$

Is this a configuration change and I have just missed a step or do we need to change our options to avoid any in the core of drush?

thanks!

weitzman commented 8 years ago

You should change your option name. --target is heavily used by the sql-* commands, and those that build upon them

whikloj commented 8 years ago

Thanks for the quick response. Is there a list of what names are not allowed when building your own commands, just in case we might have another defined elsewhere?

weitzman commented 8 years ago

A good list is at drush_get_global_options(). In addition to those, you wont want to conflict with any commands which are invoked by your command. I suspect your command is calling a sql command and that's why you have a problem.