Problem/Motivation
Over in #3086374: Make Drupal 8 & 9 compatible with PHP 7.4 I tried adding a class_alias() statement to a .module file but I discovered that the autoloader wasn't able to reference the modules classes in the main part of a module file.
Proposed resolution
Update the kernel before loading the module list.
Remaining tasks
Add tests
User interface changes
None
API changes
None
Data model changes
None
Release notes snippet
N/a
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | 3089656-15.patch | 4.68 KB | nikitagupta |
Comments
Comment #2
alexpottLet's see what breaks.
Comment #4
alexpottAh we need to still reset the implementation cache.
Comment #6
alexpottInteresting fails. I guess we need to reset the module list before the kernel update. Haven't quite worked out why.
Comment #7
dawehnerI think it would be valueable to document some more why we are doing something. @alexpott and myself had a discussion which resulted into opening up #3091588: Try to make the internal state of the module handler not changeable .
Comment #8
alexpottSo one thing that is super interesting to me is that:
Fail if instead of calling
$this->moduleHandler->setModuleList($module_filenames);before updating the kernel you call$this->moduleHandler->resetImplementations();And this is because these tests are not testing what they think they are testing. They install a module and then continue to use $this->container in the test BUT this container is no longer correct and does not have the module properly installer. #2066993: Use magic methods to sync container property to \Drupal::getContainer in functional tests has long been contentious to some but this is exactly why using $this->container in BrowserTestBase tests should be avoided therefore breaking this here is a further part to this bug fix. Updating the the previous containers module list without actually installing the modules is a recipe for very odd things occurring.
Comment #10
dawehnerResolved the remaining test failures. It turns out the reference for the module handler stayed around.
Comment #14
daffie commentedComment #15
nikitagupta commentedRerolled the patch.
Comment #16
daffie commented@nikitagupta thank you for the reroll. Now back to needs work for those tests.
Comment #21
nicxvan commentedThere is another duplicate in the extension component for this. Not closing until I link them and figure out which is the duplicate.