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

  1. Install Drupal 10.0.х/10.1.x
  2. Install Drush 12.1
  3. cp sites/default/settings.php sites/settings.php
  4. Clear sites/default/settings.php and paste
      <?php
      require_once DRUPAL_ROOT . '/sites/settings.php';
    
  5. 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

BadWebCoder created an issue. See original summary.

cilefen’s picture

Component: configuration system » other
Category: Bug report » Support request

This 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 in sites/settings.php.

szeidler’s picture

We 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_once with include to make it work.

quietone’s picture

Status: Active » Postponed (maintainer needs more info)

@BadWebCoder, has this been resolved? If so, adding a comment of what was done can help others. Thanks

szeidler’s picture

The status has been set to `Maintainer needs more info`. What kind of info is requested here?

The problem still persist for us. Any require_once and include_once are 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.

Version: 10.0.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

bumping 1 more time, I don't have an answer to #5 but don't want to close just yet.

cilefen’s picture

I 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 require to investigate?

cilefen’s picture

I meant @badwebcoder or @szeidler...

cilefen’s picture

In 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.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

quietone’s picture

Status: Postponed (maintainer needs more info) » Fixed

There 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.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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