Problem/Motivation

There are some occurrences to old /core/update.php in code and comments and all urls to /update.php are hard coded.

Proposed resolution

Since updates are integrated in full environment, i replace all of them by \Drupal::url('system.db_update').

Remaining tasks

  1. Fix and patch issue.
  2. Review issue.

Why this should be an RC target

Non disruptive minor code cleanup.
Only changes the way two links are generated to use \Drupal\Core\Url instead of hardcoding.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

GoZ’s picture

DuaelFr’s picture

Status: Needs review » Needs work
+++ b/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php
@@ -26,10 +26,10 @@ public function __construct(TranslationInterface $string_translation) {
 <li>View your <a href="!base-url">existing site</a>.</li>
 </ul>', array(
-      '!base-url' => $GLOBALS['base_url'],
+      '!update-url' => \Drupal::url('system.db_update'),

You might not want to replace !base-url because it's still used in the string.

GoZ’s picture

You are right.

Here patch

GoZ’s picture

Status: Needs work » Needs review

The last submitted patch, 1: drupal-use-routing-to-generate-update-url-2341553-1.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 3: drupal-use-routing-to-generate-update-url-2341553-3.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 3: drupal-use-routing-to-generate-update-url-2341553-3.patch, failed testing.

dawehner’s picture

I really like this issue.

GoZ’s picture

@dawehner any idea why patch fails test on d.org but succeed launching phpunit on local ?

GoZ’s picture

Status: Needs work » Needs review
FileSize
10.99 KB

Should pass tests. Updated after issue #2340251 and 0eda196d commit.

Status: Needs review » Needs work

The last submitted patch, 11: drupal-use-routing-to-generate-update-url-2341553-11.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 11: drupal-use-routing-to-generate-update-url-2341553-11.patch, failed testing.

GoZ’s picture

Status: Needs work » Needs review
FileSize
3.33 KB

Update since some of changes are integrated in -dev.

dawehner’s picture

+++ b/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php
@@ -29,6 +29,7 @@ public function __construct(TranslationInterface $string_translation) {
+      '!update-url' => \Drupal::url('system.db_update'),
...
       '!update-url' => $GLOBALS['base_path'] . 'update.php',

Note: You have a duplicate array key so still the second one is used.

Status: Needs review » Needs work

The last submitted patch, 15: drupal-use-routing-to-generate-update-url-2341553-15.patch, failed testing.

GoZ’s picture

You're right, thanks dawehner.

Any idea why tests failed here ? They passed in local calling phpunit tests.

Status: Needs review » Needs work

The last submitted patch, 18: drupal-use-routing-to-generate-update-url-2341553-18.patch, failed testing.

GoZ’s picture

Issue summary: View changes
GoZ’s picture

Status: Needs work » Needs review
FileSize
2.56 KB

I can't make interdiff. Sorry about that.

Status: Needs review » Needs work

The last submitted patch, 21: drupal-use-routing-to-generate-update-url-2341553-21.patch, failed testing.

marvin_B8’s picture

Status: Needs work » Needs review
FileSize
2.64 KB

Status: Needs review » Needs work

The last submitted patch, 23: 2341553-23-s.patch, failed testing.

DuaelFr’s picture

Removed the Url::fromRoute() call in AlreadyInstalledException as it's generating a RouteNotFoundException because it's called to early to have this route defined.

DuaelFr’s picture

Status: Needs work » Needs review

The last submitted patch, 25: interdiff.2341553.23.25.patch, failed testing.

The last submitted patch, 21: drupal-use-routing-to-generate-update-url-2341553-21.patch, failed testing.

The last submitted patch, 23: 2341553-23-s.patch, failed testing.

GoZ’s picture

Status: Needs review » Reviewed & tested by the community

We finally have a patch which passes tests.
Thanks @DuaelFr, @marvin_B8 and @dawehner.

The last submitted patch, 25: interdiff.2341553.23.25.patch, failed testing.

The last submitted patch, 21: drupal-use-routing-to-generate-update-url-2341553-21.patch, failed testing.

The last submitted patch, 23: 2341553-23-s.patch, failed testing.

DuaelFr’s picture

Issue tags: +rc target triage
xjm’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs issue summary update

Thanks for tagging this for rc target triage! To have committers consider it for inclusion in RC, we should add a statement to the issue summary of why we need to make this change during RC, including what happens if we do not make the change and what any disruptions from it are. We can add a section <h3>Why this should be an RC target</h3> to the summary.

DuaelFr’s picture

Issue summary: View changes
Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs issue summary update

The last submitted patch, 25: interdiff.2341553.23.25.patch, failed testing.

The last submitted patch, 21: drupal-use-routing-to-generate-update-url-2341553-21.patch, failed testing.

The last submitted patch, 23: 2341553-23-s.patch, failed testing.

dawehner’s picture

+++ b/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php
@@ -30,6 +30,8 @@ public function __construct(TranslationInterface $string_translation) {
+      // We cannot use the route system.db_update here because we are too early
+      // in the execution stack so we would only get a RouteNotFoundException.
       ':update-url' => $GLOBALS['base_path'] . 'update.php',

I would actually name it different. Exceptions should not rely on any subsystem, as in case you do, you result in a potential even more potential broken system.

xjm’s picture

Status: Reviewed & tested by the community » Needs work

For #40.

DuaelFr’s picture

I'd use some help there because, as a non-native speaker, I'm not sure to understand what you want :/

xjm’s picture

Issue tags: -rc target triage

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Prashant.c’s picture

Version: 8.1.x-dev » 8.3.x-dev
Prashant.c’s picture

Replacing the occurrences only for $GLOBALS['base_url'] . '/update.php'with Url::fromRoute('system.db_update') and not where /update.php was replcaed with blank using str_replace().

Adding patch against 8.3.x version.

Prashant.c’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 46: drupal-use-routing-to-generate-update-url-2341553-46.patch, failed testing.

Rajender Rajan’s picture

Rajender Rajan’s picture

Status: Needs work » Needs review

Version: 8.3.x-dev » 8.4.x-dev

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

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

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

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.

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.

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.

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

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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.

vikashsoni’s picture

I am getting this type error when applying the patch

Checking patch core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php...
warning: core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php has type 100644, expected 100755
Hunk #1 succeeded at 3 (offset -5 lines).
error: while searching for:

  • View your existing site.
  • ', array(
    ':base-url' => $GLOBALS['base_url'],
    ':update-url' => $GLOBALS['base_path'] . 'update.php',
    ));
    parent::__construct($message, $title);
    }

    error: patch failed: core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php:30
    error: core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php: patch does not apply
    Checking patch core/modules/system/src/Tests/Update/InvalidUpdateHookTest.php...
    error: core/modules/system/src/Tests/Update/InvalidUpdateHookTest.php: No such file or directory
    Checking patch core/modules/system/src/Tests/Update/UpdatesWith7xTest.php...
    error: core/modules/system/src/Tests/Update/UpdatesWith7xTest.php: No such file or directory

    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.

    Lendude’s picture

    Category: Bug report » Task
    Issue tags: +Bug Smash Initiative
    FileSize
    3.63 KB

    Updated the comment to not mention the specific exception since that doesn't really matter.

    Updated all tests to use Url::fromRoute('system.db_update'); that weren't already do so to make this consistent in core.

    Status: Needs review » Needs work

    The last submitted patch, 63: 2341553-63.patch, failed testing. View results

    voleger’s picture

    +++ b/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php
    @@ -71,7 +72,7 @@ public function testTranslatedUpdate() {
    +    $update_url = Url::fromRoute('system.db_update');
    
    +++ b/core/modules/system/tests/src/Functional/UpdateSystem/InvalidUpdateHookTest.php
    @@ -49,7 +50,7 @@ protected function setUp(): void {
    -    $this->updateUrl = $GLOBALS['base_url'] . '/update.php';
    +    $this->updateUrl = Url::fromRoute('system.db_update');
    
    +++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatesWith7xTest.php
    @@ -42,7 +43,7 @@ class UpdatesWith7xTest extends BrowserTestBase {
    -    $this->updateUrl = $GLOBALS['base_url'] . '/update.php';
    +    $this->updateUrl = Url::fromRoute('system.db_update');
    

    Lines of instantiating of Url objects require an additional ->setAbsolute()->toString() methods call.

    smustgrave’s picture

    Status: Needs work » Needs review
    FileSize
    2.15 KB
    3.71 KB

    Addressed #65

    voleger’s picture

    Looks good

    voleger’s picture

    Status: Needs review » Reviewed & tested by the community
    longwave’s picture

    Confirmed that after applying the patch that the only remaining instance of "update.php" that is manually constructed is in AlreadyInstalledException, and a comment is added to that by this patch.

    alexpott’s picture

    Status: Reviewed & tested by the community » Fixed

    Committed and pushed 2a9221d556 to 10.1.x and 31d4a1a15c to 10.0.x and a161401833 to 9.5.x. Thanks!

    Fixed the patch by moving the comment.

    Backported to 9.5.x as all code changes are to tests.

    • alexpott committed 2a9221d on 10.1.x
      Issue #2341553 by GoZ, DuaelFr, smustgrave, Prashant.c, Rajender Rajan,...

    • alexpott committed 31d4a1a on 10.0.x
      Issue #2341553 by GoZ, DuaelFr, smustgrave, Prashant.c, Rajender Rajan,...

    • alexpott committed a161401 on 9.5.x
      Issue #2341553 by GoZ, DuaelFr, smustgrave, Prashant.c, Rajender Rajan,...

    Status: Fixed » Closed (fixed)

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