Problem/Motivation
When BootstrapConfigStorageFactory::get
is called modules are not yet loaded because that function returns the very storage holding that information. So if contrib wants to provide a config storage then it needs to adds it own namespace to the classloader in settings.php. And while the classloader is in DrupalKernel it is not accessible. This got broken in #2325197: Remove drupal_classloader() when drupal_classloader
was taken away.
Proposed resolution
Pass the classloader around. Note: the doxygen and the lack of type hint is copied from DrupalKernel. However, it's only needed once. Also, while at it refactor the function very slightly to work for reinstall as well when settings.php contains a reference to an alternative backend but it is not installed yet.
Comment | File | Size | Author |
---|---|---|---|
#3 | 2370733_1.patch | 2 KB | chx |
Comments
Comment #2
chx CreditAttribution: chx commentedComment #3
chx CreditAttribution: chx commentedComment #4
chx CreditAttribution: chx commentedComment #5
larowlan@chx explained on irc that is is too hard to test - and breaks will only impact modules like mongodb anyway, so that will come back to @chx to fix most likely anyway.
Also there is no typehint for $class_loader, because it could be many varied things.
I can't find anything else to change.
Manually tested install and a few pages - all fine.
Comment #6
tstoecklerYes, this makes a lot of sense. Sorry for breaking it.
In general, passing the class loader down to places that need it is good practice and something we should be doing more (I'm looking at you,
install.php
...) because it is an inherently global object.The lack of typehinting is #2023325: Add interface for classloader so it can be cleanly swapped.
I only have one small question:
Why is
$class_loader
optional?Comment #7
Fabianx CreditAttribution: Fabianx commentedRTBC + 1, once that question is answered
Comment #8
chx CreditAttribution: chx commentedBecause the installer and LanguageServiceProvider calls BootstrapConfigStorageFactory::get . By the time LanguageServiceProvider calls this, DrupalKernel have added all modules to the classloader. Same for the installer, the InstallerKernel is built before that call.
Comment #9
chx CreditAttribution: chx commentedOpsie, didn't want to hide that.
Comment #10
tstoecklerOK, yeah that makes sense. Both the installer and the language system never cease to amaze me in their weirdness, but that's not this issue's fault.
Thanks a lot!
Comment #11
chx CreditAttribution: chx commentedComment #12
alexpottThis issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per #2350615: [policy, no patch] What changes can be accepted during the Drupal 8 beta phase?. Committed 0506d2c and pushed to 8.0.x. Thanks!
I thought about test coverage and whilst it is possible to add by writing an installer test with a custom settings.php it probably is not worth it.