0

Drush is not connecting to the correct database in a nested site structure. What can I do to debug and fix?

We have a website that consists of several nested Drupal installs/sites. I.E. The domain example.com points to a top level Drupal Site, and example.com/schools is a completely seperate Drupal install in the directory structure.

/var/www/html/example.com -> Root level website at example.com
   |
   |-> ./schools/ -> example.com/schools
   |
   |-> ./staff/ -> example.com/staff

On our live install we have Drush 9 installed on each of these sites via Composer. Each one was able to connect to their correct databases. After we updated one to Drupal 8.7 on dev, it longer connects to the correct database.

For example if I am in /var/www/html/example.com/schools and run php vendor/bin/drush status this is the output:

 Drupal version   : 8.7.8                                                     
 Site URI         : http://default                                            
 DB driver        : mysql                                                     
 DB hostname      : localhost                                                 
 DB port          : 3306                                                      
 DB username      : kpp_user                                                  
 DB name          : kpp_drupal                                                
 Database         : Connected                                                 
 Drupal bootstrap : Successful                                                
 Default theme    : kpp                                                       
 Admin theme      : adminimal_theme                                           
 PHP binary       : /usr/bin/php                                              
 PHP config       : /etc/php.ini                                              
 PHP OS           : Linux                                                     
 Drush script     : /var/www/html/example.com/vendor/drush/drush/drush     
 Drush version    : 9.7.1                                                     
 Drush temp       : /tmp                                                      
 Drush configs    : /var/www/html/example.com/vendor/drush/drush/drush.yml 
 Install profile  : standard                                                  
 Drupal root      : /var/www/html/example.com                            
 Site path        : sites/default                                             
 Files, Public    : sites/default/files                                       

So it is incorrectly using the settings.php file from the directory above it. I also tried forcing the directory root and uri with these commands but get the same output:

php vendor/drush/drush/drush --root=/var/www/html/example.com/schools status

php vendor/drush/drush/drush --uri=example.com/schools status

EDIT: I did just notice that after the update there is no /core/ folder in the schools site, so it may be that the installation is just incorrect and drush jumped up a level to find any valid Drupal install.

  • Missing /core/ directory indeed sounds odd and would explain why Drush doesn't recognize as site. Did you figure it out then? – leymannx Oct 24 '19 at 21:34
  • No. It'll probably be a very long late night fix to pull down the working live site, get it working with composer correctly, etc. But I'm pretty sure it's just because it's missing /core/ – Aaron Chamberlain Oct 24 '19 at 21:39
  • And just running $ composer install again maybe after removing the lock file and/or /vendor/ didn't do the trick to get you /core/ back? – leymannx Oct 24 '19 at 21:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.