Problem/Motivation
- #2336597: Convert path aliases to full featured entities changes the path alias storage to use a new path_alias_field_data table instead of url_alias
- when visiting update.php to run the upgrade path provided by that issue, \Drupal\system\Controller\DbUpdateController::info() outputs a link to the maintenance page, which goes through the path alias processor
- the problem is that the alias path processor tries to use the new table, which doesn't exist yet
Proposed resolution
- don't try to process path aliases during database updates: use NullPathProcessorManager in UpdateServiceProvider
- make update path tests use the UpdateKernel while running the database updates and switch to the DrupalKernel when it's done
Remaining tasks
Review.
User interface changes
Nope.
API changes
Nope.
Data model changes
Nope.
| Comment | File | Size | Author |
|---|---|---|---|
| #40 | 3006086-40-8.6.x.patch | 5.36 KB | amateescu |
| #40 | 3006086-40-test-only-8.6.x.patch | 3.45 KB | amateescu |
| #37 | 3006086-37.patch | 5.59 KB | amateescu |
| #37 | 3006086-37-test-only.patch | 3.69 KB | amateescu |
| #35 | 3006086-34-test-attempt.txt | 4.55 KB | amateescu |
Comments
Comment #2
amateescu commentedThis should do it.
Comment #3
andypostmakes sense to use ::class to populate "use" with real usage of class
Comment #4
dawehnerI do agree. executing less APIs on update time reduces in general the chance that stuff goes wrong. I'm wondering whether we should open up an issue to talk about other APIs we could basically disable at that time.
Couldn't you use
$kernel_class = DrupalKernel::classinstead here?Let's add some documentation why we choose this particular kernel.
Comment #5
amateescu commentedThank you both for the reviews!
Comment #6
amateescu commentedUgh, the interdiff doesn't include the change for #4.1, but it is included in the patch. It's just late here :)
Comment #8
amateescu commentedIt would help if we'd also assign the newly-built container.
Comment #11
amateescu commentedThis interdiff is a possible way of fixing the test fails, but I didn't go through them all because I'm starting to doubt that it's a good solution..
Comment #12
wim leersI think it makes a ton of sense that
update.phpdoes not try to resolve path aliases; it ought to depend on as little as possible.Using
NullPathProcessorManagermakes sense.AFAICT we need to change
UpdatePathTestBasebecause it's actually already wrong in HEAD, it just happens to be that we never noticed problems caused by that bug. Correct?I have to admit I don't understand why failures are happening or why #11 is fixing some of those failures. It's probably related to now finally using the correct kernel? In that case, wouldn't it be simpler to call
\Drupal::setContainer($this->container)somewhere inUpdatePathTestBase?Comment #14
amateescu commentedExactly :)
That would've been nice, but it doesn't work :/
Discussed with @alexpott and @Berdir and the problem is that the test container and the site-under-test containers have got out-of-sync, but I still don't know the proper way to fix it.
Comment #15
berdirThere is no properer way to fix this IMHO
We are now creating two different container, which means $this->container is getting out of sync. And $this->container is the old one, so it would be the opposite direction than what #12 proposed. Which already seems to happen, or getting it again from $this->container wouldn't work.
But because specific services are kept as variables we have to update them once there is a new container.
Comment #16
amateescu commentedFunny enough, it turns out that we actually do use
UpdateServiceProviderwhile running db update tests ... somehow, so there's no reason to mess with$this->containerso much. The problem I was getting in #2336597-53: Convert path aliases to full featured entities is caused by accessingupdate.phpbefore the update service provider kicks in, and it can be easily fixed by disabling path processing for\Drupal\FunctionalTests\Update\UpdatePathTestBase::$updateUrl.This patch is enough to get all the update path tests green in #2336597: Convert path aliases to full featured entities. No interdiff because it's pointless.
Comment #17
wim leersHah!
Reading this … you'd think that either of these changes would be sufficient.
Why do we need both changes?
Comment #18
amateescu commentedThe first change is needed so that when we display the contents of the
update.phppage we don't try to process the path to the maintenance mode page, and the second change is what I tried to explain in #16: don't process the path when navigating toupdate.phpin tests :)Comment #19
wim leersAlright. Damn that's tricky!
Nit: Let's use
NullPathProcessorManager::class. (@andypost also said this in #3.)Comment #21
wim leersBringing back a hunk from #8 to fix the failures.
Comment #22
wim leersAddressed #3/#19.
Comment #23
wim leersComment #24
amateescu commentedThanks, Wim! I was in a rush to write the patch from #16 and it shows :)
Comment #25
wim leersnp!
Comment #26
jibranThis looks ready to me, just some observations.
This comment is outdated now.
It is worth adding comment why path processing is set to false.
Comment #27
amateescu commentedRe #26:
1. It is not outdated, we are still working with a path processor manager, but since it doesn't have it's own interface we switched to use the one that's closest to the actual usage in
\Drupal\user\Plugin\LanguageNegotiation\LanguageNegotiationUserAdmin::isAdminPath().2. Done.
Comment #28
amateescu commentedOpened a new issue for @dawehner's request in #4: #3007572: Minimize API usage during database updates
Comment #29
amateescu commentedI think this is very much RTBC-able now. Any takers? :)
Comment #30
jibranThanks, it's ready.
Comment #31
alexpottOne question I have is what happens to URLs that are generated in update messages? As far as I know we have a few. Are we sure that we don't expect these to the processed?
Comment #32
amateescu commented@alexpott, that's a very good question :)
Another option for this issue is to disable just the alias-based path processor, like we do in
\Drupal\KernelTests\KernelTestBase::register(). That's much less invasive and should allow URLs to be generated properly in update messages.Comment #33
catch#26.2 was for a comment in UpdatePathTestBase, I think we need one there too.
Comment #34
alexpottDiscussed a bit with @amateescu in slack. I was wondering if we could add a test that asserts that update messages with urls do not use aliases and that the same url is aliases afterwards. It might not be possible but I think it is worth trying.
Comment #35
amateescu commentedAdded a comment.
I also tried to write a test for this but I couldn't get the mocked alias manager to work inside the site under test, it only works for URLs that are generated by the test itself. However, I think that any future patch that would undo this change will immediately break all of the update path tests, so we still have a lot of indirect test coverage...
Comment #36
alexpottDiscussed a bit more with @amateescu - he's going to try to use SQL to create the alias instead of using the mock. Yep we'll need to update this SQL when we move from 8.x to 9.x because we'll no longer have the path alias migration but if we don't do that then we would lose explicit test coverage of this change.
Comment #37
amateescu commentedHere we go!
Comment #40
amateescu commentedHmm, it seems we need separate patches for 8.6.x. The ones from #37 only apply to 8.7.x.
Comment #41
alexpott@amateescu the test looks good to me - thanks agin for adding this coverage.
Comment #43
amateescu commentedNo problem :) Back to RTBC then.
Comment #44
alexpottCommitted 39578f4 and pushed to 8.7.x. Thanks!
Only committed to 8.7.x because whilst this is a bug fix the bug is only really exposed by work on-going in 8.7.x therefore I don't see any advantage to committing to 8.6.x. I might be wrong and if so we can commit #40 to 8.6.x.
Removed unused uses on commit.
Comment #47
bkosborneThis issue created a bug where menu links that link to internal paths by alias will cause those paths to 404 after database updates are run (either via update.php or drush). I provided detailed steps to reproduce in the issue: #3075675: Route cache can become poisoned with invalid data during database updates, resulting in 404s.