-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drush cr causes "cannot redeclare" if function is defined in settings.php of Drupal #6214
Comments
Haven't investigated, but as a workaround, you could wrap your function in |
@greg-1-anderson Tried this. The
|
Also, when wrapping my function in To be more specific: we are using a custom function for retrieving environment variables and passing them to to the
|
Here's what we do in detail. The <?php
/**
* @param string $name
* @param mixed|null $default
*
* @return array|false|string
*/
function tm_getenv(string $name, mixed $default = NULL) {
$value = getenv($name);
if (is_string($value)) {
$value = trim($value, "\"\0\t\n\x0B\r ");
}
return $value ?: $default;
}
/**
* MODULE OR PROJECT SETTINGS
* This is for all module or project specific config/settings.
*/
foreach (glob($app_root . '/' . $site_path . '/settings/*.inc') as $filename) {
require_once $filename;
} |
What is perhaps also important: This problem does not exist with Drush 12.5 and Drupal 10.4. We use the exactly same mechanism there. |
Tried some scenarios for a workaround. The Problem with
is caused by the Settings get initialized twice as mentioned in comment 2605404404 and So the main issue here is that |
Describe the bug
When defining a custom function in
settings.php
drush cr
causes the following error:To Reproduce
Do something like follows in the
settings.php
in a Drupal project.Expected behavior
A cache rebuild is triggered.
Actual behavior
Script breaks and exits with code 1.
System Configuration
The text was updated successfully, but these errors were encountered: