Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
During the installation process, and under certain circumstances, two DrupalKernel instances are created. Of course, this slows things down a bit, but more importantly, it can be confusing when debugging as depending on where you are, you don't deal with the same instance of the Kernel, and finally it might lead to unexpected behaviors.
Proposed resolution
The patch reuses the current Kernel instance if it already exists.
Comment | File | Size | Author |
---|---|---|---|
small-optimization.patch | 891 bytes | fabpot | |
Comments
Comment #2
fabpot CreditAttribution: fabpot commentedsmall-optimization.patch queued for re-testing.
Comment #3
Sutharsan CreditAttribution: Sutharsan commentedsmall-optimization.patch queued for re-testing.
Comment #4
Crell CreditAttribution: Crell commentedThis seems reasonable, but I defer to Kat to confirm it won't cause any weird side effects.
... Who isn't in the Assigned list. I'll ping her manually. :-)
Comment #5
katbailey CreditAttribution: katbailey commentedLooks fine to me.
Comment #6
webchickCool, thanks for the patch, fabpot!
Committed and pushed to 8.x.
We should get Kat added as a maintainer of something. :)
Comment #7
sunHm.
@fabpot: Could you elaborate a bit more on the "under certain circumstances" bit?
This function is normally executed only once in the installation process and skipped once it was executed. I'm not sure how you were able to execute it more than once (which would be the only situation in which
drupal_container()
has a regular runtime kernel already, as opposed to the first time, in which the only kernel instance around is a fake/dummy kernel instance with a range of mock/null storage service overrides).