diff --git a/core/lib/Drupal/Core/Update/UpdateEarlyKernel.php b/core/lib/Drupal/Core/Update/UpdateEarlyKernel.php index 1bcab71..efb3f0c 100644 --- a/core/lib/Drupal/Core/Update/UpdateEarlyKernel.php +++ b/core/lib/Drupal/Core/Update/UpdateEarlyKernel.php @@ -7,12 +7,8 @@ namespace Drupal\Core\Update; -use Drupal\Core\DrupalKernel; -use Drupal\Core\Session\AnonymousUserSession; -use Drupal\Core\Site\Settings; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; /** * Provides a kernel with a container with just the services needed for early updated. @@ -47,7 +43,7 @@ public function discoverServiceProviders() { // Retrieve enabled modules and register their namespaces. if (!isset($this->moduleList)) { $extensions = $this->getConfigStorage()->read('core.extension'); - $this->moduleList = isset($extensions['module']) ? $extensions['module'] : array(); + $this->moduleList = isset($extensions['module']) ? $extensions['module'] : []; } $module_filenames = $this->getModuleFileNames(); $this->classLoaderAddMultiplePsr4($this->getModuleNamespacesPsr4($module_filenames)); @@ -76,7 +72,7 @@ protected function handleRaw($request) { $this->handleAccess($request); $log_filename = $this->getSitePath() . '/.ht.update_early'; - $update_early_registry = new UpdateEarlyRegistry($this->getAppRoot(), $log_filename); + $update_early_registry = new UpdatePreRegistry($this->getAppRoot(), $log_filename, 'pre_update'); // Execute all of the remaining update_early_N() implementations. $missing_update_early_N = $update_early_registry->getMissingUpdateEarlyFunctions($this); diff --git a/core/lib/Drupal/Core/Update/UpdatePreRegistry.php b/core/lib/Drupal/Core/Update/UpdatePreRegistry.php new file mode 100644 index 0000000..040072e --- /dev/null +++ b/core/lib/Drupal/Core/Update/UpdatePreRegistry.php @@ -0,0 +1,49 @@ +updateType}_NAME got executed // already. - $existing_update_functions = $this->keyValue->get('existing_updates', []); + $existing_update_functions = $this->getExecutedUpdates(); $available_update_functions = $this->getAvailableUpdateFunctions(); $not_executed_update_functions = array_diff($available_update_functions, $existing_update_functions); @@ -142,6 +142,29 @@ public function getPendingUpdateFunctions() { } /** + * Returns all the already executed updates. + * + * @return string[] + * The already executed updates. + */ + protected function getExecutedUpdates() { + return $this->keyValue->get('existing_updates', []); + } + + /** + * Sets the executed updates. + * + * @param string[] $executed_updates + * The list of executd updates + * + * @return $this + */ + protected function setExecutedUpdates(array $executed_updates) { + $this->keyValue->set('existing_updates', $executed_updates); + return $this; + } + + /** * Loads all update files for a given list of extension. * * @param \Drupal\Core\Extension\Extension[] $module_extensions @@ -211,9 +234,9 @@ public function getPendingUpdateInformation() { * @return $this */ public function registerInvokedUpdates(array $function_names) { - $executed_updates = $this->keyValue->get('existing_updates', []); + $executed_updates = $this->getExecutedUpdates(); $executed_updates = array_merge($executed_updates, $function_names); - $this->keyValue->set('existing_updates', $executed_updates); + $this->setExecutedUpdates($executed_updates); return $this; } @@ -258,13 +281,13 @@ protected function scanExtensionsAndLoadUpdateFiles() { * The module name. */ public function filterOutInvokedUpdatesByModule($module) { - $existing_update_functions = $this->keyValue->get('existing_updates', []); + $existing_update_functions = $this->getExecutedUpdates(); $remaining_update_functions = array_filter($existing_update_functions, function($function_name) use ($module) { return strpos($function_name, "{$module}_{$this->updateType}_") !== 0; }); - $this->keyValue->set('existing_updates', array_values($remaining_update_functions)); + $this->setExecutedUpdates(array_values($remaining_update_functions)); } }