Problem/Motivation

See #2501901: Allow configuring the environment via an environment variable
For update.php we can use the same kernel which used in index.php

Proposed resolution

Replace UpdateKernel with DrupalKernel.

Remaining tasks

TBD;

User interface changes

no changes

API changes

Deprecate UpdateKernel

Data model changes

Release notes snippet

CommentFileSizeAuthor
#9 3126222-nr-bot.txt143 bytesneeds-review-queue-bot
#2 3126222-2.patch11.29 KBvoleger

Comments

voleger created an issue. See original summary.

voleger’s picture

Status: Active » Needs review
StatusFileSize
new11.29 KB

First iteration. With that change I successfully performed update script for 8.8.x to 9.1.x database update.
Set 'needs review' to receive some feedback on which task left to introduce 'update' environment in core.

joachim’s picture

+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -856,6 +891,11 @@ protected function getKernelParameters() {
   protected function initializeContainer() {
+    if ($this->environment === 'update') {
+      // Always force a container rebuild, in order to be able to override some
+      // services, see \Drupal\Core\Update\UpdateServiceProvider.
+      $this->containerNeedsRebuild = TRUE;
+    }
     $this->containerNeedsDumping = FALSE;
     $session_started = FALSE;
     $all_messages = [];
@@ -1338,6 +1378,11 @@ protected function getContainerBuilder() {

@@ -1338,6 +1378,11 @@ protected function getContainerBuilder() {
    *   TRUE if the container was successfully cached.
    */
   protected function cacheDrupalContainer(array $container_definition) {
+    if ($this->environment === 'update') {
+      // Don't save this particular container to cache, so it does not leak into
+      // the main site at all.
+      return FALSE;
+    }
     $saved = TRUE;
     try {

I'm not sure this sort of change makes code more readable or more maintainable.

Currently, UpdateKernel inherits from DrupalKernel:

In cacheDrupalContainer(), UpdateKernel overrides the method completely.

In initializeContainer(), UpdateKernel sets the property before calling the parent.

To me, these seems like things that OO inheritance is good for.

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.

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.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new143 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

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.

andypost’s picture

voleger’s picture

Status: Needs work » Closed (outdated)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.