Updated: Comment #N
Problem/Motivation
We're trying to get rid of all usages of global $conf and delete/rename it. #2167109: Remove Variable subsystem discovered that the DrupalKernel still uses it for something that should be a Setting, see things like PhpStorageFactory for an example.
In HEAD in order to use this functionality in settings.php you would have to do either:
global $conf;
$conf['container_service_providers']['MyClassName'] = 'Drupal\My\Namespace\MyClassName';
or just access $GLOBALS
directly...
$GLOBALS['conf']['container_service_providers']['MyClassName'] = 'Drupal\My\Namespace\MyClassName';
This is because in Settings::initialize()
we only set up 2 globals... global $config_directories, $config;
. Because of this I think the functionality is basically broken.
Proposed resolution
Replace it with a call to Settings::getSingleton(), update code that does set this on demand.
We could add a BC-layer to Settings::initialise()
and merge $GLOBALS['conf']['container_service_providers']
with the new setting.
Remaining tasks
Agree if we want a BC layer.
Commit
User interface changes
None
API changes
Remove $GLOBALS['conf']['container_service_providers']
Add $settings['container_service_providers']
Comment | File | Size | Author |
---|---|---|---|
#50 | reroll_diff_37-50.txt | 8.65 KB | ravi.shankar |
#50 | 2183323-50.patch | 10.39 KB | ravi.shankar |
#37 | interdiff-2183323-35-37.txt | 2.78 KB | bircher |
#37 | 2183323-37.patch | 14.96 KB | bircher |
#35 | 2183323-35.patch | 13.76 KB | bircher |
Comments
Comment #1
sunIn light of #2160705: settings.php setting names are inconsistent (and undocumented), I think we should cover both of these here:
$conf['container_service_providers'] → array map of "name" to FQCN
$conf['container_yamls'] → array of service yaml filepaths
If I may ask, why do we provide two ways to register custom services?
If we're going to keep that, could we at least shorten + simplify the names?
Also, why do I need to manually specify the basename of a custom service provider class?
Long story short, I'd like to see more or less this:
Comment #2
alexpottSo actually the
$conf['container_yamls']
is already a setting.$conf['container_service_providers']
not only is class names but can be full objects. Not sure why. However I think we can convert it to a setting and break the extremely undocumented API.Comment #5
alexpottFixing installer.
Comment #8
alexpottAh I see...
Comment #9
dawehnerSo this means exising sites with stored $conf will break?
Comment #10
alexpott@dawehner how are they setting $conf... if you just to $conf['blah'] in settings .php it is not enough. We already broke that. See Settings::initialise().
Comment #11
alexpottAdded a CR https://www.drupal.org/node/2568747
I think we should do this because having something around using D7's
$GLOBALS['conf']
is super confusing.Comment #12
dawehnerWOW, I wasn't aware of that
Comment #13
BerdirEasy, we even document how:
Or..
:)
Yes, weird and very non-obvious. But it works so this *is* a change.
OK with the rename, just wanted to point it out ;)
Comment #15
alexpottRerolled
Comment #17
alexpottComment #20
alexpottDamn you pifr
Comment #21
alexpottComment #22
alexpottComment #23
alexpottDiscussed with @catch - we both feel that since you have to do
global $conf
or access$GLOBALS['conf']
directly providing a BC layer is not worth it.Comment #25
alexpottRerolled
Comment #26
alexpottComment #27
tstoecklerCan you elaborate that? What will happen with sites currently using this feature?
Comment #28
alexpott@tstoeckler they need to change. How are your sites using this feature?
Comment #29
Mile23Patch in #25 still applies to 8.1.x and 8.2.x.
Setting to 8.2.x and re-running the test.
Comment #34
bircherre-roll patch, many things have changed since this last applied, so fingers crossed!
Comment #35
bircherSmall nit: there was still a $conf in the annotation.
This was RTBC, I just re-rolled it to 8.6 so, can still be RTBC in my opinion.
Comment #36
alexpottI'm not sure if I agree with myself on BC anymore. I think we should provide BC but deprecate the usage of the global.
We're telling people how to do it. So I now think we need a BC layer.
Wrong indentation.
Comment #37
bircherI agree, we do need BC.
We use this in some cases for testing so it is definitely good to not break horribly.
I also moved the documentation part to settings.php as one would use it there.
Do we need to exercise the BC path in a test?
Comment #38
alexpott@bircher yep and ideally we need to trigger a silenced deprecation notice too.
Comment #41
neclimduloof this pattern is terrible... but yeah that's right :(
"Only allow dumping the container once the hash salt has been created." is duplicated in the new code.
Seems moving this has something to do with fixing the installer in #5 and #8 but its not clear to me how it does. Is there something we should document about why the code has to be before and how its fixing the dumping?
Also we call
Settings::get('hash_salt', FALSE))
and then immediately after callSettings::getAll()
. Should we just be using the fetched settings or is this connected to all the Setting hacks we have going on somehow?Comment #48
volegerNeeds reroll
Comment #49
volegerComment #50
ravi.shankar CreditAttribution: ravi.shankar at OpenSense Labs commentedAdded reroll of patch #37 on Drupal 9.5.x.