Problem/Motivation

#2208429: Extension System, Part III: ExtensionList, ModuleExtensionList and ProfileExtensionList makes it possible to deprecate system_rebuild_module_data() and replace it with calls to \Drupal::service('extension.list.module')->reset()

Proposed resolution

Replace all usages and deprecate system_rebuild_module_data() and trigger a silenced error. Also, when replacing the usages we should ensure that we don't unnecessarily rebuild the module list.

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

CommentFileSizeAuthor
#102 2926068-102.patch69.02 KBandypost
#102 interdiff.txt2.38 KBandypost
#99 FilterAPITest.php_.rej_.txt656 bytesandypost
#99 2926068-98.patch68.44 KBandypost
#96 2926068-96.patch68.44 KBandypost
#90 2926068-90.interdiff.txt784 bytesclaudiu.cristea
#90 2926068-90.patch68.44 KBclaudiu.cristea
#88 2926068-88.patch67.67 KBclaudiu.cristea
#88 2926068-88.interdiff.txt2.46 KBclaudiu.cristea
#84 2926068-84.patch68.1 KBandypost
#84 interdiff.txt933 bytesandypost
#83 2926068-83.patch68.1 KBandypost
#83 interdiff.txt670 bytesandypost
#82 2926068-82.patch68.1 KBandypost
#82 interdiff.txt3.92 KBandypost
#80 interdiff.txt1.52 KBYurkinPark
#80 2926068-80.patch66.66 KBYurkinPark
#78 2926068-78.patch66.85 KBandypost
#78 interdiff.txt7.02 KBandypost
#77 2926068-77.patch67.43 KBandypost
#74 2926068-74.patch67.29 KBandypost
#74 interdiff.txt707 bytesandypost
#73 2926068-73.patch66.6 KBandypost
#73 interdiff.txt4.52 KBandypost
#68 2926068-68.patch66.71 KBandypost
#68 interdiff.txt1.23 KBandypost
#66 2926068-66.patch66.62 KBandypost
#66 interdiff.txt869 bytesandypost
#64 2926068-64.patch66.63 KBandypost
#64 interdiff.txt926 bytesandypost
#62 2926068-62.patch65.91 KBandypost
#62 interdiff.txt4.8 KBandypost
#59 interdiff-2926068-58-59.txt1.61 KBvoleger
#59 2926068-59.patch66.47 KBvoleger
#58 2926068-58.patch65.99 KBvoleger
#58 interdiff-2926068-54-58.txt6.78 KBvoleger
#54 2926068-54.patch73.15 KBvoleger
#52 2926068-52.patch66.01 KBvoleger
#49 interdiff.txt713 bytesalmaudoh
#49 2926068-49.patch69.11 KBalmaudoh
#47 2926068-47.patch68.42 KBalmaudoh
#44 2926068-44.patch68.37 KBalmaudoh
#44 interdiff.txt1.08 KBalmaudoh
#42 interdiff.txt1.95 KBalmaudoh
#42 2926068-42.patch68.29 KBalmaudoh
#40 2926068-40.patch68.75 KBalmaudoh
#40 interdiff.txt2.74 KBalmaudoh
#37 interdiff.txt1.88 KBalmaudoh
#37 2926068-37.patch68.47 KBalmaudoh
#35 2926068-35.patch68.31 KBalmaudoh
#35 interdiff.txt1.11 KBalmaudoh
#34 2926068-34.patch68.31 KBalmaudoh
#34 interdiff.txt943 bytesalmaudoh
#31 2926068-31.patch67.58 KBalmaudoh
#31 interdiff.txt2.62 KBalmaudoh
#27 2926068-27.patch68.37 KBalmaudoh
#27 interdiff.txt1.38 KBalmaudoh
#26 2926068-26.patch67.25 KBalmaudoh
#26 interdiff.txt21.3 KBalmaudoh
#24 2926068-24.patch58.76 KBalmaudoh
#24 interdiff.txt12.58 KBalmaudoh
#21 2926068-21.patch51.71 KBalmaudoh
#21 interdiff.txt6.76 KBalmaudoh
#19 2926068-19.patch47.47 KBoleksiy
#19 interdiff_15-19.txt16.41 KBoleksiy
#16 2926068-15.patch33.49 KBalmaudoh
#16 interdiff.txt643 bytesalmaudoh
#13 2926068-13.patch33.49 KBalmaudoh
#2 2926068.patch48.54 KBioana apetri

Comments

alexpott created an issue. See original summary.

ioana apetri’s picture

StatusFileSize
new48.54 KB

Here is my patch, I rerolled the parent of this issue, for not getting conflicts.
See, and review it, Thanks!

almaudoh’s picture

Issue summary: View changes

@yo30: You should wait until the parent issue is committed, then you can make these changes.

If you do want to continue with this issue, then you have to find all usages of system_rebuild_module_data() and replace them with \Drupal::service('extension.list.module')->reset() or \Drupal::service('extension.list.module')->reset()->list() depending on if the return value is assigned to another variable or not. See the changelog at https://drupal.org/node/2709919.

You shouldn't reattach patch from the parent issue here.

dawehner’s picture

To be honest we should also think about, whether there are places which don't need to reset the list.

alexpott’s picture

Issue summary: View changes

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jibran’s picture

dawehner’s picture

Just doing the reset() thing is IMHO not the right idea. There should be not many places which should actually do that.

If someone want to work on it, I'm happy to assist. Please ping me on slack if you need information/guidance.

mile23’s picture

Maybe limit scope to just performing the deprecation part and not the removal and trigger error part?

dawehner’s picture

Maybe limit scope to just performing the deprecation part and not the removal and trigger error part?

That sounds like a good idea.

larowlan’s picture

Happy with a two stage process - lets just make sure we have a follow up for the second half

alexpott’s picture

I think it is important that marking the code deprecated and using @trigger_error() happen in same issue. This is because marking the code without triggering the error is just a hopeful deprecation and does not solve the problem of technical debt. I suggest that part 1 is trying to replace all the usages in core without do that.

almaudoh’s picture

Status: Active » Needs review
StatusFileSize
new33.49 KB

Let's start with replacement of system_rebuild_module_data() with ModuleExtensionList::getList(). Trying on a best effort to ::reset() only where necessary (based on code context and comments)

Status: Needs review » Needs work

The last submitted patch, 13: 2926068-13.patch, failed testing. View results

alexpott’s picture

+++ b/core/includes/install.core.inc
@@ -1501,7 +1501,7 @@ function install_profile_modules(&$install_state) {
-  $files = system_rebuild_module_data();
+  $files = $this->container->get('extension.list.module')->getList();

No $this here. Before uploading a patch it might be worth trying a test or an install as you would have caught this.

almaudoh’s picture

Status: Needs work » Needs review
StatusFileSize
new643 bytes
new33.49 KB

No $this here. Before uploading a patch it might be worth trying a test or an install as you would have caught this.

Fixed that now - copy and paste error. I was actually very sleepy and reaching for the bed at the point I uploaded that patch.

Status: Needs review » Needs work

The last submitted patch, 16: 2926068-15.patch, failed testing. View results

dawehner’s picture

  1. +++ b/core/includes/install.core.inc
    @@ -1501,7 +1501,7 @@ function install_profile_modules(&$install_state) {
       $modules = \Drupal::state()->get('install_profile_modules') ?: [];
    -  $files = system_rebuild_module_data();
    +  $files = \Drupal::service('extension.list.module')->getList();
    

    Given this is part of the installer it might need the reset.

  2. +++ b/core/includes/update.inc
    +++ b/core/includes/update.inc
    @@ -43,7 +43,7 @@ function update_check_incompatibility($name, $type = 'module') {
    
    @@ -43,7 +43,7 @@ function update_check_incompatibility($name, $type = 'module') {
    -    $modules = system_rebuild_module_data();
    +    $modules = \Drupal::service('extension.list.module')->reset()->getList();
    

    I would have guessed this one wouldn't need it

  3. +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php
    @@ -369,7 +369,7 @@ protected function createExtensionChangelist() {
         // Get a list of modules with dependency weights as values.
    -    $module_data = system_rebuild_module_data();
    +    $module_data = \Drupal::service('extension.list.module')->getList();
    
    +++ b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php
    @@ -303,7 +303,7 @@ protected function getThemeData() {
         if (!isset($this->moduleData)) {
    -      $this->moduleData = system_rebuild_module_data();
    +      $this->moduleData = \Drupal::service('extension.list.module')->getList();
    

    Should we inject the service?

  4. +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php
    @@ -329,7 +329,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
         // Get all module data so we can find dependencies and sort.
    -    $module_data = system_rebuild_module_data();
    +    $module_data = \Drupal::service('extension.list.module')->getList();
    

    +1 for not resetting this here. We have not changed the overall state of the system

  5. +++ b/core/modules/config/tests/src/Functional/ConfigImportAllTest.php
    @@ -94,7 +94,7 @@ public function testInstallUninstall() {
         system_list_reset();
    

    Do we still need the system_list_reset() call?

oleksiy’s picture

Status: Needs work » Needs review
StatusFileSize
new16.41 KB
new47.47 KB

Updated according to comment #18.

Status: Needs review » Needs work

The last submitted patch, 19: 2926068-19.patch, failed testing. View results

almaudoh’s picture

Status: Needs work » Needs review
StatusFileSize
new6.76 KB
new51.71 KB

Reverted the ->reset() in #19. Also did constructor injection for some of the classes.

One thing to decide is constructor injection for all the service classes, whether those would be a BC break.

Status: Needs review » Needs work

The last submitted patch, 21: 2926068-21.patch, failed testing. View results

dawehner’s picture

One really nice thing would be to document why we need a ->reset() in all the cases.

almaudoh’s picture

Status: Needs work » Needs review
StatusFileSize
new12.58 KB
new58.76 KB

Fixed all the test fails.

One thing to decide is constructor injection for all the service classes, whether those would be a BC break.

For this I just added an optional parameter with a getter that can initialize the value with \Drupal::service('extension.list.module') if it wasn't injected. This way the service constructor can stay backward compatible. The only exception is the RequiredModuleUninstallValidator where the constructor a non-optional constructor argument is added - this class is part of the extension system.

One really nice thing would be to document why we need a ->reset() in all the cases.

Done this too. As a matter of fact, we only needed to call ->reset() in five places.

alexpott’s picture

Status: Needs review » Needs work
  1. +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php
    @@ -180,8 +188,10 @@ class ConfigImporter {
    +   * @param \Drupal\Core\Extension\ModuleExtensionList $extension_list_module
    +   *   The module extension list
    ...
    +  public function __construct(StorageComparerInterface $storage_comparer, EventDispatcherInterface $event_dispatcher, ConfigManagerInterface $config_manager, LockBackendInterface $lock, TypedConfigManagerInterface $typed_config, ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, ThemeHandlerInterface $theme_handler, TranslationInterface $string_translation, ModuleExtensionList $extension_list_module) {
    
    @@ -191,6 +201,7 @@ public function __construct(StorageComparerInterface $storage_comparer, EventDis
    +    $this->moduleExtensionList = $extension_list_module;
    

    I think for BC it'd be nice if the argument here was optional. This class is not a service and things like Drush will have to change and it'll be complicated to support both Drupal 8.5.x and 8.6.x. Therefore I recommend making it optional and triggering a deprecation notice when its NULL.

  2. +++ b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php
    @@ -303,7 +303,7 @@ protected function getThemeData() {
    +      $this->moduleData = \Drupal::service('extension.list.module')->getList();
    

    Let's inject this. As an event subscriber it's internal and constructed via the container.

  3. +++ b/core/modules/config/tests/src/Functional/ConfigImportAllTest.php
    @@ -93,8 +93,7 @@ public function testInstallUninstall() {
    -    system_list_reset();
    -    $all_modules = system_rebuild_module_data();
    +    $all_modules = \Drupal::service('extension.list.module')->reset()->getList();
    

    Let's add a comment as to why reset().

  4. +++ b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php
    @@ -25,14 +25,7 @@ class ModuleHandlerTest extends KernelTestBase {
    -    // @todo ModuleInstaller calls system_rebuild_module_data which is part of
    -    //   system.module, see https://www.drupal.org/node/2208429.
    -    include_once $this->root . '/core/modules/system/system.module';
    

    yay

  5. +++ b/core/modules/update/src/UpdateManager.php
    @@ -82,8 +90,10 @@ class UpdateManager implements UpdateManagerInterface {
    +   * @param \Drupal\Core\Extension\ModuleExtensionList $extension_list_module
    +   *   The module extension list.
    

    If this is optional needs (optional) and |null. Not sure why this is optional because UpdateManager should be constructed via the service container. So also why is update.services.yml not changing.

  6. +++ b/core/modules/user/src/PermissionHandler.php
    @@ -229,13 +229,4 @@ protected function getModuleNames() {
    -  /**
    -   * Wraps system_rebuild_module_data()
    -   *
    -   * @return \Drupal\Core\Extension\Extension[]
    -   */
    -  protected function systemRebuildModuleData() {
    -    return system_rebuild_module_data();
    -  }
    
    +++ b/core/modules/user/tests/src/Unit/PermissionHandlerTest.php
    @@ -377,25 +368,6 @@ protected function assertPermissions(array $actual_permissions) {
    -class TestPermissionHandler extends PermissionHandler {
    -
    -  /**
    -   * Test module data.
    -   *
    -   * @var array
    -   */
    -  protected $systemModuleData;
    -
    -  protected function systemRebuildModuleData() {
    -    return $this->systemModuleData;
    -  }
    -
    -  public function setSystemRebuildModuleData(array $extensions) {
    -    $this->systemModuleData = $extensions;
    -  }
    -
    -}
    

    yay

  7. +++ b/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php
    @@ -30,10 +30,8 @@ public function register(ContainerBuilder $container) {
    -    // Rebuild system.module.files state data.
    -    // @todo Remove as part of https://www.drupal.org/node/2186491
    -    drupal_static_reset('system_rebuild_module_data');
    -    system_rebuild_module_data();
    +    // Rebuild module list state data.
    +    \Drupal::service('extension.list.module')->reset();
    
    +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigDependencyTest.php
    @@ -219,8 +219,7 @@ public function testConfigEntityUninstall() {
    -    // @todo Remove as part of https://www.drupal.org/node/2186491
    -    system_rebuild_module_data();
    +    $this->container->get('extension.list.module')->reset();
    
    @@ -361,8 +360,7 @@ public function testConfigEntityUninstallComplex(array $entity_id_suffixes) {
    -    // @todo Remove as part of https://www.drupal.org/node/2186491
    -    system_rebuild_module_data();
    +    $this->container->get('extension.list.module')->reset();
    
    @@ -478,8 +476,7 @@ public function testConfigEntityUninstallThirdParty() {
    -    // @todo Remove as part of https://www.drupal.org/node/2186491
    -    system_rebuild_module_data();
    +    $this->container->get('extension.list.module')->reset();
    

    Should we still be looking to remove these calls?

  8. +++ b/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php
    @@ -16,15 +16,6 @@
       /**
    -   * Modules to install.
    -   *
    -   * The System module is required because system_rebuild_module_data() is used.
    -   *
    -   * @var array
    -   */
    -  public static $modules = ['system'];
    

    There is likely to be a few other KernelTests where this is the case. Let's file a followup to review all tests where system is the only dependency. There are 52 tests where this is the case. For example the same code can be removed from \Drupal\Tests\field\Kernel\FieldDefinitionIntegrityTest but not from \Drupal\KernelTests\Core\Theme\ThemeInstallerTest - so working through that in a follow-up makes sense to me.

almaudoh’s picture

Status: Needs work » Needs review
StatusFileSize
new21.3 KB
new67.25 KB

Thanks for the review:
1. Done
2. Injected
3. Since I couldn't see a good reason, I removed the ->reset() and the test still passed. Great! So I went a step further and checked all the other tests that had reset() and found that it wasn't needed in many more places. Removed all of them. Tests still pass. I guess this is primarily because ModuleHandler::install() already does a reset and that is why most of these calls were made. +1 for better structured code.
4. \o/
5. Fixed. No more optional.
6. \o/
7. Removed all of them and more of the same.
8. Created #2943436: Review all tests where system module is the only dependency

almaudoh’s picture

StatusFileSize
new1.38 KB
new68.37 KB

This may be overreaching, but a couple more ->reset()s in ModuleInstaller that I don't think are needed. Tested locally and passed. Let's see what testbot says.

Status: Needs review » Needs work

The last submitted patch, 27: 2926068-27.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

alexpott’s picture

@almaudoh yeah those are unlikely to be able to be removed... it's the ModuleInstaller after all :) Can you re-upload the last green patch so the latest patch is the one to review? Thanks.

alexpott’s picture

+++ b/core/lib/Drupal/Core/Config/ConfigImporter.php
@@ -191,6 +201,7 @@ public function __construct(StorageComparerInterface $storage_comparer, EventDis
+    $this->moduleExtensionList = $extension_list_module;

We should test if it is NULL and if so trigger a deprecation error as per https://www.drupal.org/core/deprecation

almaudoh’s picture

Title: Deprecate system_rebuild_module_data() » Remove usages of system_rebuild_module_data() in core
Status: Needs work » Needs review
StatusFileSize
new2.62 KB
new67.58 KB

Reverted #27 and added a @trigger_error for #30

Also retitling to reflect actual scope per #12. I will open a follow-up to actually deprecate and @trigger_error for system_rebuild_module_data()

alexpott’s picture

Status: Needs review » Needs work

@almaudoh why wouldn't we deprecate it in this issue? This issue removes all the usages and without triggering the deprecation error we can't be sure that another issue won't sneak a usage back in.

alexpott’s picture

I think #8 to #12 has been made irrelevant by your excellent work. The patch is not that big or hard so multiple issue seems unnecessary.

almaudoh’s picture

Status: Needs work » Needs review
StatusFileSize
new943 bytes
new68.31 KB

Good point @alexpott :) Thanks. TBH, I was hoping you would say "let's just deprecate it in this issue". So done.

almaudoh’s picture

Title: Remove usages of system_rebuild_module_data() in core » Deprecate system_rebuild_module_data() and remove usages in core
StatusFileSize
new1.11 KB
new68.31 KB

Sorry, I mixed up the url in the deprecation message. Fixed it now to point to the change record.

alexpott’s picture

Status: Needs review » Needs work

Nearly there... one minor thing re the deprecation in ConfigImporter.

  1. +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php
    @@ -192,6 +192,9 @@ class ConfigImporter {
        *   (optional) The module extension list
    

    It's not optional - the optionality is deprecated. The param description should mention this.

  2. +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php
    @@ -192,6 +192,9 @@ class ConfigImporter {
    +      @trigger_error('Invoking the ConfigImporter constructor without the module extension list parameter is deprecated in Drupal 8.6.0 and will no longer be supported in Drupal 9.0.0. The extension list parameter is now required in the ConfigImporter constructor.', E_USER_DEPRECATED);
    

    We should point to a change record. I think we're going to need a new one for this issue. Very simple one that just says ConfigImporter will have a new required parameter in Drupal 9 and for now it is optional.

almaudoh’s picture

Status: Needs work » Needs review
StatusFileSize
new68.47 KB
new1.88 KB

#36 done. Change record is at https://www.drupal.org/node/2943918
#36.1: Since the optional usage is not recommended, I have removed (optional) and instead explained it in the @param description. I hope that is ok.

alexpott’s picture

Status: Needs review » Needs work

@almaudoh +1 on removing optional from the param description since the correct usage is not optional.

+++ b/core/modules/user/src/PermissionHandler.php
@@ -229,13 +229,4 @@ protected function getModuleNames() {
-  /**
-   * Wraps system_rebuild_module_data()
-   *
-   * @return \Drupal\Core\Extension\Extension[]
-   */
-  protected function systemRebuildModuleData() {
-    return system_rebuild_module_data();
-  }

This unfortunately is a BC break even though it is unused. Its usage was removed in #2281989: Add a fast and simple way to get module name from the module handler which was committed before 8.0.0 so we should have removed it then and as much as overriding the PermissionHandler is unlikely it possible so something might extend it and rely on this method. So we should not remove it. We should leave it in and deprecate and do return \Drupal::service('extension.list.module')->reset()->getList(); and yep I think we should do a reset because we have no idea of the usage.

berdir’s picture

+++ b/core/lib/Drupal/Core/Config/ConfigImporter.php
@@ -191,6 +205,7 @@ public function __construct(StorageComparerInterface $storage_comparer, EventDis
     $this->themeHandler = $theme_handler;
     $this->stringTranslation = $string_translation;
+    $this->moduleExtensionList = $extension_list_module;

The common approach is to initialize "optional" dependencies directly in the constructor, the we can avoid the lazy-loading protected method.

almaudoh’s picture

Status: Needs work » Needs review
StatusFileSize
new2.74 KB
new68.75 KB

Did #38 and #39.

alexpott’s picture

Status: Needs review » Needs work
+++ b/core/lib/Drupal/Core/Config/ConfigImporter.php
@@ -180,8 +188,14 @@ class ConfigImporter {
+    if ($extension_list_module === NULL) {
+      @trigger_error('Invoking the ConfigImporter constructor without the module extension list parameter is deprecated in Drupal 8.6.0 and will no longer be supported in Drupal 9.0.0. The extension list parameter is now required in the ConfigImporter constructor. See https://www.drupal.org/node/2943918', E_USER_DEPRECATED);
+    }

@@ -191,6 +205,10 @@ public function __construct(StorageComparerInterface $storage_comparer, EventDis
+    $this->moduleExtensionList = $extension_list_module;
+    if ($this->moduleExtensionList === NULL) {
+      $this->moduleExtensionList = \Drupal::service('extension.list.module');
+    }

No need to the two ifs... normally this is done like this:

    if ($extension_list_module === NULL) {
      @trigger_error('Invoking the ConfigImporter constructor without the module extension list parameter is deprecated in Drupal 8.6.0 and will no longer be supported in Drupal 9.0.0. The extension list parameter is now required in the ConfigImporter constructor. See https://www.drupal.org/node/2943918', E_USER_DEPRECATED);
      $this->moduleExtensionList = \Drupal::service('extension.list.module');
    }
    else {
      $this->moduleExtensionList = $extension_list_module;
    }
almaudoh’s picture

Status: Needs work » Needs review
StatusFileSize
new68.29 KB
new1.95 KB

Ah, well. Didn't really think that mattered that much...

mile23’s picture

Status: Needs review » Needs work
Issue tags: +Needs followup, +@deprecated
+++ b/core/lib/Drupal/Core/Config/ConfigImporter.php
@@ -180,8 +188,18 @@ class ConfigImporter {
+   * @param \Drupal\Core\Extension\ModuleExtensionList|null $extension_list_module
+   *   The module extension list. This is left optional for BC reasons, but the
+   *   optional usage is deprecated and will become required in Drupal 9.0.0.

Is there a follow-up against D9 to make this change? We should make one and add a @todo. Also link the follow-up from the change record.

almaudoh’s picture

Status: Needs work » Needs review
Issue tags: -Needs followup
StatusFileSize
new1.08 KB
new68.37 KB

Status: Needs review » Needs work

The last submitted patch, 44: 2926068-44.patch, failed testing. View results

almaudoh’s picture

Status: Needs work » Needs review
StatusFileSize
new68.42 KB

Reroll

Status: Needs review » Needs work

The last submitted patch, 47: 2926068-47.patch, failed testing. View results

almaudoh’s picture

Status: Needs work » Needs review
StatusFileSize
new69.11 KB
new713 bytes

A new usage of ConfigImporter was added using the signature this patch has deprecated.

andypost’s picture

  1. +++ b/core/lib/Drupal/Core/Extension/module.api.php
    @@ -131,7 +131,7 @@ function hook_module_implements_alter(&$implementations, $hook) {
    - * This hook is invoked in _system_rebuild_module_data() and in
    + * This hook is invoked in \Drupal\Core\Extension\ExtensionList::getList() and in
    

    line length overflows 80 chars

  2. +++ b/core/modules/system/system.module
    @@ -1046,8 +1046,14 @@ function _system_rebuild_module_data() {
    +  @trigger_error("system_rebuild_module_data() is deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. Instead, you should use \\Drupal::service('extension.list.module')->getList(). See https://www.drupal.org/node/2709919", E_USER_DEPRECATED);
    

    Two \\

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

voleger’s picture

StatusFileSize
new66.01 KB

Rerolled.
Addressed #50.2 Replaced \\ => \
#50.1 - outdated.

Status: Needs review » Needs work

The last submitted patch, 52: 2926068-52.patch, failed testing. View results

voleger’s picture

StatusFileSize
new73.15 KB

Rerolled again.

voleger’s picture

Status: Needs work » Needs review
alexpott’s picture

+++ b/core/modules/config/tests/src/Functional/ConfigImportAllTest.php
--- /dev/null
+++ b/core/modules/config/tests/src/Functional/ConfigImportAllTest.php.orig

This can be removed from the patch.

Status: Needs review » Needs work

The last submitted patch, 54: 2926068-54.patch, failed testing. View results

voleger’s picture

StatusFileSize
new6.78 KB
new65.99 KB

Sure

voleger’s picture

Status: Needs work » Needs review
StatusFileSize
new66.47 KB
new1.61 KB

Missed use core/modules/system/src/Form/ModulesListForm.php

Status: Needs review » Needs work

The last submitted patch, 59: 2926068-59.patch, failed testing. View results

andypost’s picture

It looks like parts with cache cleaning needs more detailed review but here's a quick skim

  1. +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php
    @@ -180,8 +188,20 @@ class ConfigImporter {
    +      @trigger_error('Invoking the ConfigImporter constructor without the module extension list parameter is deprecated in Drupal 8.6.0 and will no longer be supported in Drupal 9.0.0. The extension list parameter is now required in the ConfigImporter constructor. See https://www.drupal.org/node/2943918', E_USER_DEPRECATED);
    

    update to 8.7.0 needed

  2. +++ b/core/lib/Drupal/Core/Extension/RequiredModuleUninstallValidator.php
    @@ -41,11 +49,17 @@ public function validate($module) {
    +    try {
    +      return $this->moduleExtensionList->get($module)->info;
    +    }
    +    catch (\InvalidArgumentException $e) {
    +      // @todo Replace with dedicated exception
    +      // https://www.drupal.org/project/drupal/issues/2940203
    +      return [];
    

    Could use to check that module exists instead of exception

  3. +++ b/core/modules/filter/tests/src/Functional/FilterFormTest.php
    @@ -71,8 +71,6 @@ public function testFilterForm() {
    -    // Force rebuild module data.
    -    \Drupal::service('extension.list.module')->reset();
    

    now clear why removed

  4. +++ b/core/modules/filter/tests/src/Kernel/FilterAPITest.php
    @@ -488,7 +488,7 @@ public function testDependencyRemoval() {
    -    $module_data = \Drupal::service('extension.list.module')->reset()->getList();
    +    $module_data = \Drupal::service('extension.list.module')->getList();
    

    looks wrong change

  5. +++ b/core/modules/user/src/PermissionHandler.php
    @@ -233,9 +233,14 @@ protected function getModuleNames() {
    +   * @deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. This
    +   *   method is no more required because system_rebuild_module_data() has been
    +   *   removed from Drupal 8.6.0. See https://www.drupal.org/node/2709919
    ...
       protected function systemRebuildModuleData() {
    -    return system_rebuild_module_data();
    +    @trigger_error('PermissionHandler::systemRebuildModuleData() is deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. It is no more required because system_rebuild_module_data() has been removed from Drupal 8.6.0. See https://www.drupal.org/node/2709919', E_USER_DEPRECATED);
    

    8.7.0 and looks could be removed

andypost’s picture

Status: Needs work » Needs review
Related issues: +#3017360: Replace theme handler with theme installer in ConfigImporter
StatusFileSize
new4.8 KB
new65.91 KB

Fix install tests and address comments #61

Status: Needs review » Needs work

The last submitted patch, 62: 2926068-62.patch, failed testing. View results

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new926 bytes
new66.63 KB

Fix installer

almaudoh’s picture

From interdiff at #62

  1. +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php
    @@ -335,7 +335,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
    +    $module_data = \Drupal::service('extension.list.module')->reset()->getList();
    

    I don't think we need the ->reset() here.

  2. +++ b/core/lib/Drupal/Core/Extension/RequiredModuleUninstallValidator.php
    @@ -52,14 +54,10 @@ public function validate($module) {
    -    catch (\InvalidArgumentException $e) {
    

    How are we handling the exception now?

andypost’s picture

StatusFileSize
new869 bytes
new66.62 KB

I agree that uninstall should not rebuild list - patch does it
#65.2

+++ b/core/lib/Drupal/Core/Extension/RequiredModuleUninstallValidator.php
@@ -52,14 +54,10 @@ public function validate($module) {
+    if ($this->moduleExtensionList->exists($module)) {

the exists() cares about it

alexpott’s picture

  1. This is looking very nearly there. Nice.
  2. +++ b/core/modules/system/src/Form/ModulesUninstallForm.php
    @@ -78,11 +90,11 @@ public function buildForm(array $form, FormStateInterface $form_state) {
    +    $uninstallable = array_filter($this->moduleExtensionList->getList(),
    +      function ($module) {
    +        return empty($module->info['required']) && $module->status;
    +      });
    

    The code formatting here does not look quite right. The closing ); should not be indented.

  3. +++ b/core/modules/system/system.module
    @@ -1028,8 +1028,14 @@ function _system_rebuild_module_data() {
    + *
    + * @deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0.
    + *   Use \Drupal::service('extension.list.module')->getList() instead.
    + *
    + * @see https://www.drupal.org/node/2709919
      */
     function system_rebuild_module_data() {
    +  @trigger_error('system_rebuild_module_data() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Instead, you should use \Drupal::service("extension.list.module")->getList(). See https://www.drupal.org/node/2709919', E_USER_DEPRECATED);
       return \Drupal::service('extension.list.module')->reset()->getList();
     }
    

    We have no legacy test of this. I think that is okay because there is no logic inside this.

    I wonder if we should note about resetting the list as this method has normally done that so telling people to do \Drupal::service('extension.list.module')->getList() will not always work for them if a reset() was required.

andypost’s picture

StatusFileSize
new1.23 KB
new66.71 KB

Fixed 2 and added note for 3.

berdir’s picture

Status: Needs review » Needs work

A few minor nitpicks, setting to needs work for that, otherwise mostly just some more or less random thoughts...

  1. +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php
    @@ -180,8 +188,20 @@ class ConfigImporter {
    +    if ($extension_list_module === NULL) {
    +      @trigger_error('Invoking the ConfigImporter constructor without the module extension list parameter is deprecated in Drupal 8.7.0 and will no longer be supported in Drupal 9.0.0. The extension list parameter is now required in the ConfigImporter constructor. See https://www.drupal.org/node/2943918', E_USER_DEPRECATED);
    +      $this->moduleExtensionList = \Drupal::service('extension.list.module');
    +    }
    +    else {
    +      $this->moduleExtensionList = $extension_list_module;
    

    our deprecation messages for constructor arguments are pretty inconsistent but yay for having one.

  2. +++ b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php
    @@ -38,10 +39,13 @@ class ConfigImportSubscriber extends ConfigImportValidateEventSubscriberBase {
        * Constructs the ConfigImportSubscriber.
        *
    +   * @param \Drupal\Core\Extension\ModuleExtensionList $extension_list_module
    +   *   The module extension list.
        * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
        *   The theme handler.
        */
    -  public function __construct(ThemeHandlerInterface $theme_handler) {
    +  public function __construct(ModuleExtensionList $extension_list_module, ThemeHandlerInterface $theme_handler) {
    +    $this->moduleExtensionList = $extension_list_module;
         $this->themeHandler = $theme_handler;
       }
    

    I suppose we expect that nobody is extending this, which is probably fair, but adding arguments first is still a bit uncommon although I suppose it makes sense for being the more important one?

  3. +++ b/core/modules/config/src/Form/ConfigSingleImportForm.php
    @@ -138,8 +146,10 @@ class ConfigSingleImportForm extends ConfirmFormBase {
        */
    -  public function __construct(EntityManagerInterface $entity_manager, StorageInterface $config_storage, RendererInterface $renderer, EventDispatcherInterface $event_dispatcher, ConfigManagerInterface $config_manager, LockBackendInterface $lock, TypedConfigManagerInterface $typed_config, ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, ThemeHandlerInterface $theme_handler) {
    +  public function __construct(EntityManagerInterface $entity_manager, StorageInterface $config_storage, RendererInterface $renderer, EventDispatcherInterface $event_dispatcher, ConfigManagerInterface $config_manager, LockBackendInterface $lock, TypedConfigManagerInterface $typed_config, ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, ThemeHandlerInterface $theme_handler, ModuleExtensionList $extension_list_module) {
         $this->entityManager = $entity_manager;
         $this->configStorage = $config_storage;
    

    there seems to be one subclass of this in contrib, but it doesn't override the constructor.

  4. +++ b/core/modules/config/src/Form/ConfigSync.php
    @@ -129,8 +137,10 @@ class ConfigSync extends FormBase {
        */
    -  public function __construct(StorageInterface $sync_storage, StorageInterface $active_storage, StorageInterface $snapshot_storage, LockBackendInterface $lock, EventDispatcherInterface $event_dispatcher, ConfigManagerInterface $config_manager, TypedConfigManagerInterface $typed_config, ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, ThemeHandlerInterface $theme_handler, RendererInterface $renderer) {
    +  public function __construct(StorageInterface $sync_storage, StorageInterface $active_storage, StorageInterface $snapshot_storage, LockBackendInterface $lock, EventDispatcherInterface $event_dispatcher, ConfigManagerInterface $config_manager, TypedConfigManagerInterface $typed_config, ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, ThemeHandlerInterface $theme_handler, RendererInterface $renderer, ModuleExtensionList $extension_list_module) {
         $this->syncStorage = $sync_storage;
    

    Finding 2-3 subclasses, one in config_distro even overrides create() but they do it in a way that's compatible with changes

  5. +++ b/core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php
    @@ -197,7 +197,7 @@ protected function checkDisplayOption($entity_type_id, $field_id, BaseFieldDefin
        */
       protected function modulesWithSubdirectory($subdirectory) {
    -    $modules = system_rebuild_module_data();
    +    $modules = $this->container->get('extension.list.module')->getList();
         $modules = array_filter($modules, function (Extension $module) use ($subdirectory) {
           // Filter contrib, hidden, already enabled modules and modules in the
    

    I'll never understand understand why everyone is using $this->container in tests...

  6. +++ b/core/modules/help/tests/src/Kernel/HelpEmptyPageTest.php
    @@ -32,7 +32,7 @@ public function register(ContainerBuilder $container) {
        */
       public function testEmptyHookHelp() {
    -    $all_modules = system_rebuild_module_data();
    +    $all_modules = $this->container->get('extension.list.module')->getList();;
    

    double semicolon nitpick

  7. +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceRestTestCoverageTest.php
    @@ -29,7 +29,7 @@ class EntityResourceRestTestCoverageTest extends BrowserTestBase {
     
    -    $all_modules = system_rebuild_module_data();
    +    $all_modules = $this->container->get('extension.list.module')->getList();;
         $stable_core_modules = array_filter($all_modules, function ($module) {
    

    another one

  8. +++ b/core/modules/system/src/Form/ModulesUninstallConfirmForm.php
    @@ -66,12 +74,15 @@ class ModulesUninstallConfirmForm extends ConfirmFormBase {
        *   The configuration manager.
        * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
        *   The entity manager.
    +   * @param \Drupal\Core\Extension\ModuleExtensionList $extension_list_module
    +   *   The module extension list
    

    missing "."

    Somewhat interesting that ModuleExtensionList doesn't have an interface and even has an explicit @internal and documentation about how it's not yet stable, considering that we're adding a ton of injections and type hints on it now...

  9. +++ b/core/modules/system/src/Form/ModulesUninstallForm.php
    @@ -78,11 +90,12 @@ public function buildForm(array $form, FormStateInterface $form_state) {
    -    // Get a list of all available modules.
    -    $modules = system_rebuild_module_data();
    -    $uninstallable = array_filter($modules, function ($module) use ($modules) {
    -      return empty($modules[$module->getName()]->info['required']) && $module->status;
    -    });
    +    // Get a list of all available modules that can be uninstalled.
    +    $uninstallable = array_filter($this->moduleExtensionList->getList(),
    +      function ($module) {
    +        return empty($module->info['required']) && $module->status;
    +      }
    +    );
    

    merging this all in one statement makes it tricky to review, especially due to the $modules change, which seems to be fine. The newline *before* the anonymous function call is a bit unusual though?

  10. +++ b/core/modules/system/tests/src/Kernel/System/InfoAlterTest.php
    @@ -22,14 +22,14 @@ class InfoAlterTest extends KernelTestBase {
        */
       public function testSystemInfoAlter() {
         \Drupal::state()->set('module_required_test.hook_system_info_alter', TRUE);
    -    $info = system_rebuild_module_data();
    +    $info = \Drupal::service('extension.list.module')->getList();
    

    interestingly, this test for example uses the (preferred by me) Drupal::service(), looks like quite a few people worked on the patch over time, resulting in some inconsistencies like this, injection order and so on.

  11. +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRecreateTest.php
    @@ -50,7 +50,8 @@ protected function setUp() {
       }
    

    we sure have a lot of new ConfigImporter(...) in all these tests, might be worth to have a helper trait or base class for these config tests?

almaudoh’s picture

...I'll never understand understand why everyone is using $this->container in tests...

...interestingly, this test for example uses the (preferred by me) Drupal::service(),...

I have had this dilemma myself. So, question - what is the recommended option to use in tests (since I see an equal number of both \Drupal::service('xyz') and $this->container->get('xyz')

This would help in other patches as well.

andypost’s picture

berdir’s picture

Status: Needs review » Needs work

True, but I didn't set it to needs work because of that but to fix those nitpicks.

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new4.52 KB
new66.6 KB

Re-roll and address #69 5-9

IIRC service() vs container was supposed to use container in kernel tests and service() in other ones
I changed usage to notion used in each specific file to be consistent - so it will be easy to replace when there will be conclusion in one of issues from #71

andypost’s picture

StatusFileSize
new707 bytes
new67.29 KB

Fixed failed test

@Berdir it really needs kind of trait for config importer in #3017360: Replace theme handler with theme installer in ConfigImporter

dawehner’s picture

  1. +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php
    @@ -180,8 +188,20 @@ class ConfigImporter {
    +  public function __construct(StorageComparerInterface $storage_comparer, EventDispatcherInterface $event_dispatcher, ConfigManagerInterface $config_manager, LockBackendInterface $lock, TypedConfigManagerInterface $typed_config, ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, ThemeHandlerInterface $theme_handler, TranslationInterface $string_translation, ModuleExtensionList $extension_list_module = NULL) {
    ...
    +      $this->moduleExtensionList = $extension_list_module;
    

    May I ask why we sometimes use extension_list_module and sometimes moduleExtensionList. Is there any reason to not have more symmetry?

  2. +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php
    @@ -83,7 +83,9 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
         if ($enable_dependencies) {
           // Get all module data so we can find dependencies and sort.
    -      $module_data = system_rebuild_module_data();
    +      // The module list needs to be reset so that it can re-scan and include
    

    May I ask whether someone did some benchmarking? I could imagine that this helps a bit with installing an install profile.

  3. +++ b/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php
    @@ -15,15 +15,6 @@
    -   * Modules to install.
    -   *
    -   * The System module is required because system_rebuild_module_data() is used.
    -   *
    -   * @var array
    -   */
    -  public static $modules = ['system'];
    

    Nice!

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

andypost’s picture

StatusFileSize
new67.43 KB

Reroll, #75.1 because argument following service name but variable following class name

andypost’s picture

StatusFileSize
new7.02 KB
new66.85 KB

Clean-up constructor argument (should be last)

voleger’s picture

Status: Needs review » Needs work
+++ b/core/lib/Drupal/Core/Config/ConfigImporter.php
@@ -180,8 +188,20 @@ class ConfigImporter {
+    if ($extension_list_module === NULL) {
+      @trigger_error('Invoking the ConfigImporter constructor without the module extension list parameter is deprecated in Drupal 8.7.0 and will no longer be supported in Drupal 9.0.0. The extension list parameter is now required in the ConfigImporter constructor. See https://www.drupal.org/node/2943918', E_USER_DEPRECATED);
+      $this->moduleExtensionList = \Drupal::service('extension.list.module');
+    }
+    else {
+      $this->moduleExtensionList = $extension_list_module;
+    }

We could simplify it now to be able to remove only 4 lines instead of removing 4 lines and modifying of 3 lines in Drupal 9 depreciation cleanup.
Let's keep 'if' construction without 'else'.

YurkinPark’s picture

Status: Needs work » Needs review
StatusFileSize
new66.66 KB
new1.52 KB

Patch rerolled and fixes are implemented

alexpott’s picture

Status: Needs review » Needs work
+++ b/core/lib/Drupal/Core/Config/ConfigImporter.php
@@ -180,8 +188,18 @@ class ConfigImporter {
+      @trigger_error('Invoking the ConfigImporter constructor without the module extension list parameter is deprecated in Drupal 8.7.0 and will no longer be supported in Drupal 9.0.0. The extension list parameter is now required in the ConfigImporter constructor. See https://www.drupal.org/node/2943918', E_USER_DEPRECATED);

+++ b/core/modules/system/system.module
@@ -1032,8 +1032,15 @@ function _system_rebuild_module_data() {
+ * @deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0.
+ *   Use \Drupal::service('extension.list.module')->getList() instead.
+ *   Note: use reset() only when you really need to rescan and rebuild the list.
...
+  @trigger_error('system_rebuild_module_data() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Instead, you should use \Drupal::service("extension.list.module")->getList(). See https://www.drupal.org/node/2709919', E_USER_DEPRECATED);

We need to update this to 8.8.0 now.

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new3.92 KB
new68.1 KB

Changed version and added test

andypost’s picture

StatusFileSize
new670 bytes
new68.1 KB

and comment

andypost’s picture

StatusFileSize
new933 bytes
new68.1 KB

And fix typo

voleger’s picture

Status: Needs review » Reviewed & tested by the community

All comments were addressed. Looks good.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Not a huge fan of unit testing this.

+++ b/core/modules/system/tests/src/Unit/SystemFunctionsLegacyTest.php
@@ -0,0 +1,35 @@
+/**
+ * Tests deprecated system module functions.
+ *
+ * @group system
+ * @group legacy
+ */
+class SystemFunctionsLegacyTest extends UnitTestCase {
...
+    require_once __DIR__ . '/../../../system.module';

Here's why this code is now included for all tests after this has run if you multiple phpunit tests. Doesn't happen for run-tests.sh because of how we run them. Imo a kernel test that installs system and calls the function is safer.

alexpott’s picture

+++ b/core/lib/Drupal/Core/Config/ConfigImporter.php
@@ -180,8 +188,18 @@ class ConfigImporter {
+      @trigger_error('Invoking the ConfigImporter constructor without the module extension list parameter is deprecated in Drupal 8.8.0 and will no longer be supported in Drupal 9.0.0. The extension list parameter is now required in the ConfigImporter constructor. See https://www.drupal.org/node/2943918', E_USER_DEPRECATED);

+++ b/core/modules/system/system.module
@@ -1032,8 +1032,15 @@ function _system_rebuild_module_data() {
+ * @deprecated in Drupal 8.8.0 and will be removed before Drupal 9.0.0.
+ *   Use \Drupal::service('extension.list.module')->getList() instead.
+ *   Note: use reset() only when you really need to rescan and rebuild the list.
...
+  @trigger_error('system_rebuild_module_data() is deprecated in Drupal 8.8.0 and will be removed before Drupal 9.0.0. Instead, you should use \Drupal::service("extension.list.module")->getList(). See https://www.drupal.org/node/2709919', E_USER_DEPRECATED);

We need to update these to make them as per the standard. See #3024461: Adopt consistent deprecation format for core and contrib deprecation messages

Apparently we're not using the new format yet so let's wait on this.

claudiu.cristea’s picture

Status: Needs work » Needs review
StatusFileSize
new2.46 KB
new67.67 KB

Fixed #86. Regarding #87, I don't think we should wait for the policy issue as that waits for a coding standards rule. For actual deprecations we should go with the current deprecation policy and this patch fulfills that policy. When a new policy will be in place we, probably, will bulk update all the existing deprecations to use it.

Status: Needs review » Needs work

The last submitted patch, 88: 2926068-88.patch, failed testing. View results

claudiu.cristea’s picture

Status: Needs work » Needs review
StatusFileSize
new68.44 KB
new784 bytes

New occurrence in HEAD.

almaudoh’s picture

Status: Needs review » Reviewed & tested by the community

Re-RTBC since committer comment in #86 has been addressed and test is passing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 90: 2926068-90.patch, failed testing. View results

jibran’s picture

Status: Needs work » Reviewed & tested by the community

Random fails.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 90: 2926068-90.patch, failed testing. View results

andypost’s picture

Status: Needs work » Reviewed & tested by the community
andypost’s picture

StatusFileSize
new68.44 KB

reroll for 2 hunks

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Needs another reroll.

alexpott’s picture

+++ b/core/modules/update/src/UpdateManager.php
@@ -82,8 +90,10 @@ class UpdateManager implements UpdateManagerInterface {
+   * @param \Drupal\Core\Extension\ModuleExtensionList $extension_list_module
+   *   The module extension list.
    */
-  public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, UpdateProcessorInterface $update_processor, TranslationInterface $translation, KeyValueFactoryInterface $key_value_expirable_factory, ThemeHandlerInterface $theme_handler) {
+  public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, UpdateProcessorInterface $update_processor, TranslationInterface $translation, KeyValueFactoryInterface $key_value_expirable_factory, ThemeHandlerInterface $theme_handler, ModuleExtensionList $extension_list_module) {
     $this->updateSettings = $config_factory->get('update.settings');
     $this->moduleHandler = $module_handler;
     $this->updateProcessor = $update_processor;
@@ -92,6 +102,7 @@ public function __construct(ConfigFactoryInterface $config_factory, ModuleHandle

@@ -92,6 +102,7 @@ public function __construct(ConfigFactoryInterface $config_factory, ModuleHandle
     $this->themeHandler = $theme_handler;
     $this->availableReleasesTempStore = $key_value_expirable_factory->get('update_available_releases');
     $this->projects = [];
+    $this->moduleExtensionList = $extension_list_module;
   }

The new argument here needs to be optional. Whislt I agree that event and form constructor don;t need to do the optional service dance I think things like the service should. Thanks @Berdir for checking the state of contrib.

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new68.44 KB
new656 bytes

reroll

andypost’s picture

+++ b/core/modules/update/src/UpdateManager.php
@@ -129,7 +140,7 @@ public function getProjects() {
-        $module_data = system_rebuild_module_data();
+        $module_data = $this->moduleExtensionList->reset()->getList();

@alexpott do you mean to use private getter here?

alexpott’s picture

Nope I mean we need to make the new argument in UpdateManager optional like we are doing for ConfigImporter

andypost’s picture

StatusFileSize
new2.38 KB
new69.02 KB

Here it is

claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community

This issues has been once RTBCed, in #91. I'm reviewing and RTBCing for changes requested in #98.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 23fad5b and pushed to 8.8.x. Thanks!

  • alexpott committed 23fad5b on 8.8.x
    Issue #2926068 by almaudoh, andypost, voleger, claudiu.cristea, Oleksiy...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.