Problem/Motivation
I previously opened this issue here https://github.com/drush-ops/drush/issues/5739 but I was told that this is not a Drush problem, but most likely PHP or Drupal
My sites settings consist of two parts: in site/settings.php, where the main site settings are located, and in site/default/settings.php, where individual settings are located, depending on the working environment (database, mail configs, etc. ). In site/default/settings.php I include the main settings via require_once DRUPAL_ROOT . '/sites/settings.php';
If I run drush cache:rebuild, I get an error:
Missing $settings['hash_salt'] in settings.php
And if I transfer $settings['hash_salt'] from site/settings.php to site/default/settings.php directly, then the error disappears.
Also, drush does not see the directory settings for the public directory, for example. And instead of the sites/default/files/public I specified, it sees sites/default/files
But if, for example, transfer the database settings to sites/settings.php and run drush sql-dump --result-file=sites/default/files/public/dump.sql, then the dump will be successfully done. Or if you run drush config-export, it will export to the directory specified in site/settings.php.
That is, the site/settings.php loads correctly, but for some reason some values are ignored
Steps to reproduce
The problem can be reproduced on pure Drupal
- Install Drupal 10.0.х/10.1.x
- Install Drush 12.1
cp sites/default/settings.php sites/settings.php- Clear
sites/default/settings.phpand paste
<?php require_once DRUPAL_ROOT . '/sites/settings.php'; - Run
drush cache:rebuild
And your will get error:
Missing $settings['hash_salt'] in settings.php
Ubuntu + Apache 2.4.52 + PHP 8.1.14
Comments
Comment #2
cilefen commentedThis is not the configuration system. This is not a bug in Drupal. You are running a custom setup using PHP language primitives like require_once.
Probably
$settings['hash_salt']is being unset or set to an empty string insites/settings.php.Comment #3
szeidler commentedWe see a similar behavior after having upgraded to Drush 12.
We also include a different file in our settings.php. We needed to replace our
include_oncewithincludeto make it work.Comment #4
quietone commented@BadWebCoder, has this been resolved? If so, adding a comment of what was done can help others. Thanks
Comment #5
szeidler commentedThe status has been set to `Maintainer needs more info`. What kind of info is requested here?
The problem still persist for us. Any
require_onceandinclude_onceare misbehaving for us. It's not a big deal, we can easily change it to the without `_once` function. Not sure if it is drush or Drupal core causing it.Comment #7
smustgrave commentedbumping 1 more time, I don't have an answer to #5 but don't want to close just yet.
Comment #8
cilefen commentedI don't think Drupal can have any influence directly over the behavior of require, require_once, include, or include_once in PHP. Perhaps the file has already been included in a prior bootstrap phase which overwrote values. @szeidler or @szeidler: have you traced Drush's execution to the point of the
requireto investigate?Comment #9
cilefen commentedI meant @badwebcoder or @szeidler...
Comment #10
cilefen commentedIn case my comment was vague, I am saying that the most likely situation is that the file has already been included by some other code, and that proving that should be straightforward on your end using built-in PHP debugging tools.
Comment #12
quietone commentedThere has been no further discussion on this in 10 months and so far, the indication is that this is not something core can fix, see #8.
I am closing this per the guidance in Handle or refer a support request in an issue.