Problem/Motivation
https://www.drupal.org/node/3018145
The sync directory is defined in $settings and not $config_directories
Proposed resolution
In #3154341: Doesn't detect the $config_directories deprecation we attempted a runtime check for this, but that turned out to be futile due to how https://git.drupalcode.org/project/drupal/-/blob/8.9.x/core/lib/Drupal/C... copies the value both ways, so once that runs, we cannot tell if the setting was set or the global was set as both will be set. If they are different, $settings['config_sync_directory']; will prevail so they will also never be different. So we cannot really check this by merely looking at runtime values.
Include settings.php and gather values that way.
Remaining tasks
Commit.
User interface changes
When using both values:
When using only the deprecated value:
When using only the non-deprecated value or neither:
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #34 | 3224660-fix-undeclared-variables.patch | 588 bytes | dave reid |
| #27 | 3224660--config-directories-depreciation-not-detected-27.patch | 6.37 KB | seismicmike |
| #23 | 3224660-23.patch | 5.49 KB | gábor hojtsy |
| #19 | 2021-07-26_19-00-20.png | 96.31 KB | laura.gates |
| #16 | Screenshot 2021-07-26 at 13.27.39.png | 292.54 KB | gábor hojtsy |
Issue fork upgrade_status-3224660
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:



Comments
Comment #3
gábor hojtsyCarrying reporter credits for #3154341: Doesn't detect the $config_directories deprecation for @tedbow.
Comment #4
gábor hojtsyI think I have a rough idea. The settings object require's settings.php and encapsulates the values. We could do the same, just need the precise location of the settings file for the request. That could be gained from the DrupalKernel. We need a clean way to get the kernel already constructed for the page. Something along these lines:
Comment #5
gábor hojtsyHere is an untested implementation.
Comment #6
gábor hojtsyConsider it lightly tested now :D Needs more manual testing.
Comment #7
gábor hojtsyWhitespace fixes.
Comment #8
gábor hojtsyApparently it is also registered on the container by itself, so we can also get it from there.
Comment #9
gábor hojtsyParent it to the right place.
Comment #10
dydave commentedHi Gabor,
Thanks very much for the patch.
Just tested it on:
8.9.178.x-3.8Patch from #8 applied fine but I'm getting the following messages now:
See screenshot:
When I'm actually using the following in
settings.php:With this code in settings.php, I would expect the warnings to be gone, or green, since this is what is recommended at:
The sync directory is defined in $settings and not $config_directories
Please let me know if there's anything I've been doing wrong or missed, in the config or the usage of the module.
Sorry, but I haven't had time to look further in code where the problem could come from.
Thanks in advance for your help.
Comment #11
gábor hojtsyWow, how would both of them appear?! I think you applied this on top of 3.8 which did have an older and incorrect version of this check. Can you try with the dev version instead? Thanks!
Comment #12
dydave commentedThanks a lot Gabor for your prompt and clear reply it's greatly appreciated.
I've tested again with your advice with the dev version:
drupal/upgrade_status (dev-3.x 04edb37)with the patch from #8, which applied nicely...
and it worked! See screenshot below:
Thanks a lot Gabor, once again.
As far as I'm concerned, this can be considered RTBC.
Comment #13
alisonSame here! -- applied the patch from #8 to upgrade_status (
drupal/upgrade_status:3.x-dev@dev) -- the$config_directoriesrequirement on the upgrade status report page accurately lists a status of "✅ Not used" 🎉Comment #14
lomale@bluewin.ch commentedThe Dev Version has made the error message gone.
#10 -> #12
But I have a problem with the scan function. I already had that before.
see picture Scan button
The Button is not activated.
Thanks Lothar
Comment #15
gábor hojtsy@lomale@bluewin.ch: in this case you should see an error message at the top of the page explaining why is it not possible.
Comment #16
gábor hojtsyI used drupalpod.com to test this out properly. Here is the rundown of how it looks in various settings.php configurations:
When using both values:
When using only the deprecated value:
When using only the non-deprecated value or neither:
Also updated the issue summary.
Comment #17
gábor hojtsyFurther update issue summary to include links.
Comment #18
gábor hojtsyComment #19
laura.gatesI'm not sure if this was expected or not... but running ddev on my project and it has several different settings for settings.ddev.php that run
if (version_compare)resulting in this being flagged twice.For what it's worth, it may be good to tell upgrade status to ignore docker+ applications (lando, docksal, ddev, etc) to ignore managed php files.
Comment #20
gábor hojtsyBased on that code, ddev will only set the deprecated value if on prior to Drupal 8.8.0, and that is neither supported in terms of upgrade path to Drupal 9 as per the first line item in Upgrade Status' environment report, neither receives security support anymore. We could add an extra condition to not check for this variable if the site is pre-Drupal 8.8.0 to be extra careful (so people don't update a setting that their site does not yet support).
Comment #21
nessunluogo commentedJust for reporting, I'm having a similar issue as DYdave in #10. I just don't have the double message but only the "Use of $config_directories in settings.php is deprecated..." error. I'm also using ddev as laura.gates does.
Updating to the dev version fixed the issue.
BTW I think #20 is a good idea.
Comment #23
gábor hojtsyWrapped the new code in this condition so that should be ddev-friendly now :)
Comment #25
gábor hojtsyCommitted that!
Comment #26
esthertempel commentedUpdating from the 3.8.0 release to 3.x-dev@dev fixed the issue for me.
The upgrade status report page shows a status of "Not used"
Thanks!
Comment #27
seismicmike commentedComposer wouldn't install the dev version for me for some reason, so I rolled the following patch. This can be applied to the current release (8.x-3.8) until a new release with this fix and the rollback from https://www.drupal.org/project/upgrade_status/issues/3154341 is provided. This patch will roll back the previous fix and apply the fix from this issue.
Comment #28
dave reidThis is causing a fatal error in some of our sites where we are using some anonymous functions in our settings.php to modify the $settings and $config objects, possibly due to re-loading the settings.php file on the same request.
Comment #29
gábor hojtsy@Dave Reid: there is a similar problem at #3227807: Notice: Constant already defined due to constants defined in settings.php. I did not quite expect settings.php to have side effects like either of yours, but since that is happening, any bright ideas as to how could we detect this deprecation while (a) not including the settings twice (b) unable to check if the setting was in fact migrated due to the backwards compatibility layer as we explored in #3154341: Doesn't detect the $config_directories deprecation previously.
Comment #30
dave reidSo I think that system_requirements has a check for this as well, and it does not trigger this error for us when we load that page. It looks like it just checks the $GLOBALS variable without re-loading settings.php:
Comment #31
dave reidI don't think there's a need to even load the settings file again, we should be able to accomplish the same using $GLOBALS and the \Drupal\Core\Site\Settings class:
Comment #32
gábor hojtsy@Dave Reid: hm, we tried checking $GLOBALS but figured out in #3224551: Warning about $config_directories deprecation will never get resolved, roll it back that is always set as per https://git.drupalcode.org/project/drupal/-/blob/8.9.x/core/includes/boo... when/if config_get_config_directory() is called. Yes that itself is a deprecated function but we cannot know if that was invoked or not in the environment where we assume various deprecated things get called.
Comment #33
dave reidOh that's truly unfortunate that the old global was filled in with the new value and not the other way around, that's just not great, oof.
Comment #34
dave reidSo the specific error I'm seeing in our settings.php is that when we attempt to include it the second time, the variable $config is NULL, instead of an array. It looks like setting the same three variables to empty arrays, just like \Drupal\Core\Site\Settings::initialize() does resolves it locally for me. And gives a cleaner inspection of the actual settings as well.
This could also be fixed by using include_once or require_once in our settings.php file of our sub-settings files, which we will also do in our code, but the attached patch I would suggest for inclusion and release.
Comment #35
gábor hojtsy@Dave Reid: Thanks! I opened #3228576: Fix variable errors when including settings file the second time for tracking purposes and credited you there. Moved the patch to there.
Comment #36
gábor hojtsyComment #37
mccoolai commentedHi Gábor,
I am having a similar issue that was stated in comment #10. I uninstalled the module and used composer to download drupal/upgrade_status 3.x-dev@dev and reinstalled it in my Drupal project.
I was expecting to clear the error status but it was still present, I dumped the value and for some reason, the global variable $config_directories still has a value assigned to it.
I even cleared the cache and truncated the tables in the DB just to be sure it's not cache but to no avail. Please see screenshots below:
Also, a note - I am using DevDesktop by Acquia for my local environment. There might be something that I missed but any guidance would be much appreciated.
Comment #38
gábor hojtsy@mccoolai: thanks for reporting your issue at #3229552: Deprecated $config_directories still detected with 3.x-dev even though it should not, we can keep discussing there.
Comment #40
sam.foster commentedHi folks
I too was getting this issue and found it to be the fault of the
$config_directories['sync'] = $repo_root . "/config/default";
line that was in my /vendor/acquia/blt/settings/config.settings.php file
I'm using BLT 11.5, but I suspect I should have upgraded that to a higher version and will be doing that shortly as part of the move to Drupal9
I was getting the reported config_directory error on my local (not deployed yet - just working locally with the upgrade status module)
HTH
Sam