Drush 12 don't see some settings that are added via require_once in settings.php

Created on 24 August 2023, over 1 year ago
Updated 5 February 2024, about 1 year ago

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

💬 Support request
Status

Postponed: needs info

Version

10.0

Component
Other 

Last updated 2 days ago

Created by

🇷🇺Russia BadWebCoder

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @BadWebCoder
  • 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.

  • 🇩🇪Germany szeidler Berlin

    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.

  • Status changed to Postponed: needs info about 1 year ago
  • 🇳🇿New Zealand quietone

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

  • 🇩🇪Germany szeidler Berlin

    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.

Production build 0.71.5 2024