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

Created on 24 August 2023, almost 2 years 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

πŸ› Bug report
Status

Active

Version

10.0 ✨

Component
OtherΒ  β†’

Last updated 4 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 over 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.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

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

  • I don't think Drupal can have any influence directly over the behavior of require, require_once, include, or include_once in PHP. Perhpaps 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?

  • I meant @badwebcoder or @szeidler...

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

Production build 0.71.5 2024