Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Fix and patch issue.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.
Comment | File | Size | Author |
---|---|---|---|
#66 | 2341553-66.patch | 3.71 KB | smustgrave |
#66 | interdiff-63-66.txt | 2.15 KB | smustgrave |
Comments
Comment #1
GoZ CreditAttribution: GoZ commentedHere the patch.
Comment #2
DuaelFrYou might not want to replace !base-url because it's still used in the string.
Comment #3
GoZ CreditAttribution: GoZ commentedYou are right.
Here patch
Comment #4
GoZ CreditAttribution: GoZ commentedComment #9
dawehnerI really like this issue.
Comment #10
GoZ CreditAttribution: GoZ commented@dawehner any idea why patch fails test on d.org but succeed launching phpunit on local ?
Comment #11
GoZ CreditAttribution: GoZ commentedShould pass tests. Updated after issue #2340251 and 0eda196d commit.
Comment #15
GoZ CreditAttribution: GoZ commentedUpdate since some of changes are integrated in -dev.
Comment #16
dawehnerNote: You have a duplicate array key so still the second one is used.
Comment #18
GoZ CreditAttribution: GoZ commentedYou're right, thanks dawehner.
Any idea why tests failed here ? They passed in local calling phpunit tests.
Comment #20
GoZ CreditAttribution: GoZ at Centarro commentedComment #21
GoZ CreditAttribution: GoZ at Centarro commentedI can't make interdiff. Sorry about that.
Comment #23
marvin_B8 CreditAttribution: marvin_B8 as a volunteer and at comm-press commentedComment #25
DuaelFrRemoved the Url::fromRoute() call in AlreadyInstalledException as it's generating a RouteNotFoundException because it's called to early to have this route defined.
Comment #26
DuaelFrComment #30
GoZ CreditAttribution: GoZ at Centarro commentedWe finally have a patch which passes tests.
Thanks @DuaelFr, @marvin_B8 and @dawehner.
Comment #34
DuaelFrComment #35
xjmThanks 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.Comment #36
DuaelFrComment #40
dawehnerI 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.
Comment #41
xjmFor #40.
Comment #42
DuaelFrI'd use some help there because, as a non-native speaker, I'm not sure to understand what you want :/
Comment #43
xjmComment #45
Prashant.cComment #46
Prashant.cReplacing the occurrences only for
$GLOBALS['base_url'] . '/update.php'
withUrl::fromRoute('system.db_update')
and not where /update.php was replcaed with blank usingstr_replace().
Adding patch against 8.3.x version.
Comment #47
Prashant.cComment #49
Rajender Rajan CreditAttribution: Rajender Rajan as a volunteer and at gai Technologies Pvt Ltd for gai Technologies Pvt Ltd commentedComment #50
Rajender Rajan CreditAttribution: Rajender Rajan as a volunteer and at gai Technologies Pvt Ltd for gai Technologies Pvt Ltd commentedComment #60
vikashsoni CreditAttribution: vikashsoni as a volunteer and at Zyxware Technologies commentedI 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:
', 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
Comment #63
LendudeUpdated 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.
Comment #65
volegerLines of instantiating of Url objects require an additional
->setAbsolute()->toString()
methods call.Comment #66
smustgrave CreditAttribution: smustgrave at Mobomo commentedAddressed #65
Comment #67
volegerLooks good
Comment #68
volegerComment #69
andypostRTBC++
Comment #70
longwaveConfirmed 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.
Comment #71
alexpottCommitted 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.