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

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review
StatusFileSize
new1.44 KB

Let's see what breaks.

Status: Needs review » Needs work

The last submitted patch, 2: 3089656-2.patch, failed testing. View results

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new684 bytes
new1.49 KB

Ah we need to still reset the implementation cache.

Status: Needs review » Needs work

The last submitted patch, 4: 3089656-4.patch, failed testing. View results

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new869 bytes
new1.55 KB

Interesting fails. I guess we need to reset the module list before the kernel update. Haven't quite worked out why.

dawehner’s picture

StatusFileSize
new2.18 KB
new2.18 KB

I 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 .

alexpott’s picture

StatusFileSize
new2.72 KB
new4.12 KB

So one thing that is super interesting to me is that:

  • Drupal\Tests\media\Functional\UrlResolverTest
  • Drupal\Tests\system\Functional\System\TrustedHostsTest

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.

Status: Needs review » Needs work

The last submitted patch, 8: 3089656-8.patch, failed testing. View results

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new5.09 KB
new989 bytes

Resolved the remaining test failures. It turns out the reference for the module handler stayed around.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

daffie’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests, +Needs reroll
nikitagupta’s picture

Status: Needs work » Needs review
StatusFileSize
new4.68 KB

Rerolled the patch.

daffie’s picture

Status: Needs review » Needs work
Issue tags: -Needs reroll

@nikitagupta thank you for the reroll. Now back to needs work for those tests.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

nicxvan’s picture

Component: base system » extension system

There is another duplicate in the extension component for this. Not closing until I link them and figure out which is the duplicate.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.