Can't really figure out whether this is a dupe of #1848998: Problems with update_module_enable(), so opening a new issue, and pinging from there.

When a module is enabled in an update with update_module_enable(),
subsequent calls to \Drupal::get('module.manager')->loadInclude() for files on this module will fail,
because ModuleManager::$moduleList does not get updated after update_module_enable().

update_module_enable() calls system_list_reset(), but it seems that function does not interact with the ModuleManager - it does have a drupal_static_reset('system_rebuild_module_data'), but that's not enough now that the list of modules is also statically cached in ModuleManager ?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yched’s picture

Status: Active » Needs review
FileSize
780 bytes

Naive patch ?

yched’s picture

Best without the stray debug()

yched’s picture

Title: update_module_enable() does not update moduleList the ModuleHandler » update_module_enable() does not update ModuleHandler::$moduleList

Fix title

chx’s picture

Status: Needs review » Postponed

All update issues are postponed on #1949724: Allow simpletest child sites to additionally load a test-specific settings.php to allow testing anonymous and configless updates. Especially those that mess with the lower underpinnings.

yched’s picture

Status: Postponed » Needs review

Unpostponing, then.

webchick’s picture

Status: Needs review » Needs work

The last submitted patch, update_module_enable-1941000-2.patch, failed testing.

yched’s picture

As per @chx instructions, closing as a duplicate of #1848998: Problems with update_module_enable().

yched’s picture

The getSchema() method in /core/modules/field/lib/Drupal/field/Plugin/Core/Entity/Field.php is currently forced to use module_load_install() instead of $module_handler->loadInclude(),
- the latter fails because the $module_handler has a stale moduleList when a module was just enabled with update_module_enable(),
- module_load_install() currently does its job without relying on the moduleHandler, and thus "just works".

yched’s picture

Status: Needs work » Needs review
FileSize
953 bytes

So, that's *so* not the only issue with update_module_enable() :-)...
- It doesn't include the module file, so it's impossible to call any function provided by the module.
- It doesn't register the module to the autoloader, so it's impossible to load any class provided by the module.

Attached are the workarounds I needed to add to unbreak upgrade tests in #1969728: Implement Field API "field types" as TypedData Plugins.
Totally not sure whether those are the "right" fixes, but at least this keeps track of what's currently broken.

Also, this is definitely not a dupe of #1848998: Problems with update_module_enable() as is currently stands.

chx’s picture

Status: Needs review » Closed (duplicate)

But it is a duplicate of #2001310: Disallow firing hooks during update which includes #11 or something very close to it.