From d3c440008dc643639647b2688c7ef1ba92748caf Mon Sep 17 00:00:00 2001 From: catch Date: Wed, 10 Aug 2022 10:39:27 +0900 Subject: [PATCH] Issue #3294299 by phma, alexpott, pooja saraah, mikelutz: Regression in functional test performance with a large number of modules (cherry picked from commit fea90e524fc2feb2783e492773a10801907a3ac6) --- core/lib/Drupal/Core/Update/UpdateRegistry.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/core/lib/Drupal/Core/Update/UpdateRegistry.php b/core/lib/Drupal/Core/Update/UpdateRegistry.php index 8428018bbe9..60a8ffa67dc 100644 --- a/core/lib/Drupal/Core/Update/UpdateRegistry.php +++ b/core/lib/Drupal/Core/Update/UpdateRegistry.php @@ -96,7 +96,7 @@ class UpdateRegistry implements EventSubscriberInterface { * A list of post-update functions that have been removed. */ public function getRemovedPostUpdates($extension) { - $this->scanExtensionsAndLoadUpdateFiles(); + $this->scanExtensionsAndLoadUpdateFiles($extension); $function = "{$extension}_removed_post_updates"; if (function_exists($function)) { return $function(); @@ -246,7 +246,7 @@ class UpdateRegistry implements EventSubscriberInterface { * A list of update functions. */ public function getUpdateFunctions($extension_name) { - $this->scanExtensionsAndLoadUpdateFiles(); + $this->scanExtensionsAndLoadUpdateFiles($extension_name); $all_functions = $this->getAvailableUpdateFunctions(); return array_filter($all_functions, function ($function_name) use ($extension_name) { @@ -276,15 +276,24 @@ class UpdateRegistry implements EventSubscriberInterface { /** * Scans all module, theme, and profile extensions and load the update files. + * + * @param string|null $extension + * (optional) Limits the extension update files loaded to the provided + * extension. */ - protected function scanExtensionsAndLoadUpdateFiles() { + protected function scanExtensionsAndLoadUpdateFiles(string $extension = NULL) { // Scan for extensions. - $extension_discovery = new ExtensionDiscovery($this->root, FALSE, [], $this->sitePath); + $extension_discovery = new ExtensionDiscovery($this->root, TRUE, [], $this->sitePath); $module_extensions = $extension_discovery->scan('module'); $theme_extensions = $this->includeThemes() ? $extension_discovery->scan('theme') : []; $profile_extensions = $extension_discovery->scan('profile'); $extensions = array_merge($module_extensions, $theme_extensions, $profile_extensions); + // Limit to a single extension. + if ($extension) { + $extensions = array_intersect_key($extensions, [$extension => TRUE]); + } + $this->loadUpdateFiles($extensions); }