Problem/Motivation
We have to replace all left usages of _url, just 123 of them ...
Postponed on #2369225: Add $options['base_url'] to UrlGenerator::generateFromRoute()
Postponed on #2350837: Convert most usages of EntityInterface::getSystemPath() to use routes
Blocks #2343669: Remove _l() and _url()
Beta phase evaluation
| Issue category | Task because there is no bug it is fixing, and is not a feature. Just replacing old style code. |
|---|---|
| Issue priority | Critical because this blocks another critical #2343669: Remove _l() and _url() |
According to https://www.drupal.org/core/beta-changes , since this is a critical, it can proceed in the beta.
Proposed resolution
Remove the majority of _url() calls. Because of specific complications for some uses, and because additional uses have crept in since the creation of this issue, the remaining uses will be handled in
- _l(): will be removed as part of #2343669: Remove _l() and _url()
- Views usages followups: #2409209: Replace all _url() calls beside the one in _l()
Remaining tasks
| Task | Novice task? | Contributor instructions | Complete? |
|---|---|---|---|
| Reroll the patch if it no longer applies. | Instructions | Yes |
User interface changes
None.
API changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #215 | interdiff-211-213.txt | 1.69 KB | mpdonadio |
| #215 | replace_most_existing-2364157-213.patch | 109.71 KB | mpdonadio |
| #211 | interdiff-207-211.txt | 1.63 KB | mpdonadio |
| #211 | replace_most_existing-2364157-211.patch | 109.17 KB | mpdonadio |
| #207 | interdiff-201-207.txt | 666 bytes | mpdonadio |
Comments
Comment #1
dawehner.
Comment #2
dawehnerSome starting work.
Comment #4
dawehnerSome more work and no fatal later :)
Comment #6
martin107 commentedsmall-step forward.
less brackets.
Comment #8
mpdonadioGoing to try to fix as many of the exceptions and syntax errors as possible, and then triage the fails into common groups.
Comment #9
dawehner@mpdonadio++
Comment #10
mpdonadioCommon error #1:
No idea what this means.
Common error #2:
There are similar problems with bad route names. Drupal\Tests\Core\UrlTest passes, so I suspect all of these fails need test mocking for urlGenerator.
Comment #11
mpdonadioFixed a few syntax errors. Mainly want to see what testbot says for SimpleTestBrowserTest, as I there this may be a PHP 5.4 vs 5.5 complication for me to diagnose.
My comment above about mocking is wrong, as these are all webtests (ie, simpletest) and not unit tests. I assume something is wrong with all of these in the setup to make the routes available.
Comment #12
mpdonadioIt looks like the view.frontpage.page_1route problem is solved by simply adding views to the list of modules installed by the test. Is this bad?
Comment #14
martin107 commentedPatch needed reroll, No conflicts, just auto-merging
Comment #16
mpdonadioI think this fixed all of the HAL failures, but need to see what TestBot says about FileNormalizeTest.
Comment #18
mpdonadioNow I think all of the HAL stuff is fixed.
Comment #19
mpdonadioComment #20
mpdonadioReattaching w/ proper status for testbot to run this.
Comment #21
martin107 commentedReturning to #12
Not bad. Using the routing is needed.. and so enabling the module is a must..
In any event - the dependencies of the test, are now apparent for the next developer to see and maybe object to..
Comment #23
mpdonadioAll of the Search fails are because the route is used in the test module, so you need to add the dependency to the search_extra_type.info.yml and not the test.
The fail in GlossaryTest was a simple type in the route name.
I am going to see if I can fix TokenReplaceTest before I post my next patch, but the error isn't obvious.
Comment #25
mpdonadioFew more fixes that were explained in #23. I expect these failures:
Drupal\language\Tests\LanguageUILanguageNegotiationTest, Drupal\language\Tests\LanguageUrlRewritingTest - The test looks correct, but it looks like Url::fromRoute is ignoring the language when it is making the link.
PageCacheTagsIntegrationTest - Something is wrong with the URL generation for the nodes; the page that gets generated is a 404.
TokenReplaceTest - I don't get what this error really means.
Unassigning myself, as I won't be able to look at this for a little while.
Comment #27
martin107 commentedRegarding Drupal\language\Tests\LanguageUILanguageNegotiationTest
I am posting a couple of observations, I don't regard this as anywhere near a fix....
Url::fromRoute() is used in a few places to create strings which will be compared to a reference string starting 'https:://'
well if you want that then in addition to 'https' => TRUE, another key - value pair is needed. 'absolute' => TRUE.
looking at Url::fromRoute() 'script' is not a valid option, so I have removed it..
Comment #29
martin107 commentedReroll, No conflicts just merging.
Comment #31
martin107 commentedLike #27 this is a nudge is the correct direction not a fix, for anything...
I have correctly annotated the new function
ViewExecutable::getUrlInfo() - which highlighted to me that it returns a \Drupal\Core\Url object
Which in turn highlights that the line from TokenReplaceTest should be changed :-
I am still debugging this but as the code then flows into PathPluginBase::getUrlInfo the new error results from the fact that $route_names is an empty array.
I am posting this partial update in the hope the solution will be obvious to others.
Or Maybe tomorrow night, for me.
Comment #32
mpdonadioFew quick comments, but I think we need @dawehner's input here.
The absolute option for the language tests is not present it 8.0.x, so I don't see why it is needed here.
PageCacheTagsIntegrationTest is failing b/c the base URL is getting tacked on, and then drupalGet is also prepending it. So, the URL is eg
http://localhost:8888/drupal-8.0.x/drupal-8.0.x/node/1If you change the test to
$this->drupalGet($url->setAbsolute()->toString());then the test passes. I don't want to just change the test to make it pass w/o confirming that this is correct.
TokenReplaceTest is still a mystery. I think @martin107 is right about needing toString(), but the exception suggests a bigger problem that it can't find the route or display for 'test_tokens.page_1', which doesn't make sense.
Comment #34
mpdonadio@timplunkett set me down the right path with TokenReplaceTest; I have that fixed locally.
Looking an the language problems again to see if I can fix them before I post another patch.
Comment #35
mpdonadioThis fixes PathPluginBase, which makes TokenReplaceTest pass.
Nothing looks obviously wrong with the language tests. I went through the UI, enabled language, added Italian, configured it for URL (like the tests that are failing) and the URLs, and then added the switcher block. The link for italian is wrong, so I think something is wrong with the url generator itself. Trying to raise someone on IRC to help me confirm this.
Comment #37
martin107 commentedThanks, @mpdonadio and @timplunkett...
Ah its obvious when you see it... I hope the mantra of post early and post often ... is not seen as too much noise on a critical issue :)
So I am looking at the test results and the first arrays returned in error labelled PageCacheTagsIntegrationTest.php line 147
I have pretty printed the 2 arrays out to get some perspective as a.txt and b.txt with the difference file diff-a-b.txt
In short what this reveals is that the following 4 elements from the PageCacheTag are missing causing the comparison to fail
I can't explain the filter_fomr:basic_html thing ....But my hunch is that ....it looks like something that was working is now unexpectedly returns an empty string.
As always I hope digging into the details joggs someone's brain into providing the solution.
On a minor note I have reintroduced the annotations associated with ViewExecutable::getUrlInfo() as they were the not part of the error I made as #31 was skipped over.
Comment #39
mpdonadio@martin107, are you running tests locally? If so, do you see the same behavior I describe in #32 with the wrong fetched and resulting in a 404 (and hence different headers), and having ->setAbsolute() fix it?
Comment #40
martin107 commentedRegarding PageCacheTagsIntegrationTest
When I try locally ( Nov 4th 16:46 UTC+0 ) it passes locally on my machine ( with 20 passes )
In the time between last known bad [ November 4, 2014 at 10:01am ] and now there have been 4 commits.
So I am retesting ... just to make sure.
My local testing is based on php5.5.10 using run-test.sh
browser testing fails, but I think that maybe a memory allocation thing at my end...
Comment #43
berdirDid not look at the patch at all yet, but I suspect this overlaps quite a bit with #2350837: Convert most usages of EntityInterface::getSystemPath() to use routes ?
Comment #44
dawehner@Berdir
Well in that case the other issue is just purely named :) we are removing _url() calls, ... thought it seems to be that the amount of interaction is okayish.
@mpdonadio
Maybe you could have a look at the linked issue and figure out the exact intersections and remove it from this patch for now?
Comment #45
mpdonadio@dawehner, will do. I started a bash script to identify touched files in both patches, which will make this a fairly easy task. Comments on my observations in #32 and #35 would be appreciated, too, to keep this moving.
Comment #46
mpdonadioBased on that, the patches only overlap on two files:
core/modules/rest/src/Tests/AuthTest.php
core/modules/node/src/Tests/NodeTranslationUITest.php
The hunks for AuthTest are similar, but different. The change in entity-system-path-2350837-15 looks more better. I will yank that out of this patch.
The hunks for NodeTranslationUITest are in different portions. That will stay, though there may be clashes later on.
Comment #48
mpdonadioComment #52
mpdonadioI made an issue related to the NodeTranslationUITest failure, #2369225: Add $options['base_url'] to UrlGenerator::generateFromRoute(), as I see the same behavior in HEAD with the Language Switcher block. As I mention in that issue, I thin the core problem has to do with routes mishandling the language option, but I don't know enough about this to confirm or deny it.
I will dig into the cause of the LanguageUrlRewritingTest fail to see if it is a test problem, or a code problem. But, my first look seems to indicate that some of the tests may not be valid with proper routes / URL, so we need to decide how to handle this. I will triage this.
Comment #53
berdirOn #44: No, the other issue is not poorly named. It's just that getSystemPath() return values eventually have to be passed through url(), so to be able to get rid of them, we also have to remove the _url() calls down the line. I posted it because I suspected that I've already solved some problem here over there.
Comment #54
mpdonadioIf #2369225: Add $options['base_url'] to UrlGenerator::generateFromRoute() gets committed, then I think this is good, and worthy of a proper review.
I removed the absolute=TRUE from LanguageUILanguageNegotiationTest, as that is not correct, and LanguageNegotiationUrl::processOutbound() will generate an absolute URL anyway for domain based negotiation. There is a slight quirk in this test with regards to running the test on something other than port 80/443, but I don't think that is worth addressing in the test per some of the other comments about "Base path gives problems on the testbot, so $correct_link is hard-coded." in that file. If desired, we could hard code the port that the test is running on into the $correct_link.
The fix to PageCacheTagsIntegrationTest() is a bit of a hack, but it is a side effect of taking a URL, converting it into a string (which prepends the base path), then using that in WebTestBase::drupalGet(), which will then call UrlGenerator::generateFromPath(), which tacks on the base path again. So, the ->setAbsolute() in the patch gets around this. I am going to experiment with this and file a new issue if warranted (pretty sure this is a patchable bug in UrlGenerator::generateFromPath() wrt the ltrim logic in the middle).
Comment #56
mpdonadioComment #57
mpdonadioComment #59
mpdonadioComment #60
xjmComment #61
yesct commentedadding blocker tag, since this blocks #2343669: Remove _l() and _url(), so that the d8 blockers is accurate. Remove the blocker tag when this issue is fixed, and unpostpone 2343669 if this was the last blocker of that.
Comment #62
yesct commentedComment #63
mpdonadioRe-roll wasn't bad. Setting Needs Review to see where we stand on fails.
Comment #65
mpdonadioBack to Postponed. The fail in AddFeedTest is from a missing `use`. The other two are expected, and should be fixed when #2369225: Add $options['base_url'] to UrlGenerator::generateFromRoute() gets committed (I'll verify this later).
Also did a quick search, and we will need to do another pass for new uses of _url() that have crept in.
Comment #66
mpdonadioBlocking issue was committed; will have patch soon.
Comment #67
mpdonadioThis should come up green. However, PhpStorm is telling me there are 55 usages left in code, and 3 in comments. I'll work on the ones outside of tests first, and get that to green. Then I will update the tests.
Comment #68
mpdonadioComment #69
mpdonadioChanged my mind and did all of the tests first.
I'm wondering if we should add a static method to Url that more closely resembles _url(), that would be more generic that fromUri and fromRoute, something like
From looking at the remaining usages, there seem to be a decent amount of cases where there is a string that can be a path from a route, a non-routable path, or an external path. This would make the switch easier.
Comment #71
mpdonadioWell that was embarrassing. I'm surprised there weren't more fails with what I just fixed...
Comment #72
mpdonadioSmall manual merge when I did the rebase this morning (just added a use to a test).
Interdiffs are before the rebase, just to show what I changed.
Tests use the `Url::fromUri('base://' . $path)->toString()` pattern, as this is what was done in earlier work.
The functions that actually fetch data use the url generator service.
Comment #73
tim.plunkettThis is a routed URL, I think it's
aggregator_test.redirectJust hit enter
Comment #74
dawehnerWorking on fixing a couple of points in my review ...
@tim
No you are wrong. ... its a typo, on purpose
We can use routes here for all of them ... pretty sure
It is alright to make that here, i just was not perfectly happy.
I'm pretty sure that we don't want to use the url_generator here ... is there really a reason to do so?
Can we fix that here? The change was needed because we need the proper route to be there ... Given that though the question is whether we should better use a dedicated test path for that
Those seems to be existing routes?
Mh, do we need the url generator here?
It is a shame that we havent' converted poor statistics yet.
Could we use $view->display_handler->getUrlInfo() for this issue?
For those we do have the information about the route name and parameters available.
Comment #75
mpdonadioYeah, we need to do a good pass through this to see where routes are available and use them when possible.
#74-4, #74-7, WebTestBase::drupalGet() uses the URL generator, so I changed those two to also use it. So, everything that does actual fetching uses the URL generator, but assertions use the URL class.
#74-9: $view->display_handler->getUrlInfo() was throwing an exception about the route for the display not being available. Head scratcher.
Comment #76
mpdonadio@dawehner, if you are going to fix some of this, here is my work in progress from my repo. You should probably take a look at the new method I added to URL anyway to see if it is a good idea.
Comment #78
dawehner@mpdonadio
Well I think we should really try to convert it properly and use route names.
Worked on my feedback ... sadly I don't get the BreadcrumbTest working.
Comment #80
dawehner... fixed a couple of more instances.
Comment #82
dawehnerSome fixes.
Comment #84
dawehnerYou shall not PASS, when you break the installer.
Comment #86
mpdonadioSimple reroll b/c a new behavior in core/modules/field_ui/field_ui.js
Comment #88
mpdonadioMostly easy reroll. Few manual merges.
Comment #90
mpdonadioFixed a bunch of the easy things.
I expect two groups of fails:
ImageStylesPathAndUrlTest is failing on the non-clean URL test, because a clean URL is being generated. Didn't poke much into it.
The rest seem to be related to recursive router rebuilds. Tried a few things, but didn't fire up a debugger to really dive into where the recursion is coming from.
Comment #92
mpdonadioAnother reroll was needed while I was debugging this... Manual merge in EntityReferenceItem; chose what was in HEAD.
Comment #94
berdirThis patch doubled in size in comment #84, there's a ton of changes in field_ui that doesn't seem related to this. Are you sure this isn't a bad reroll in there? My guess would be the add field patch that landed around then.
I'm wondering if we should focus on #2350837: Convert most usages of EntityInterface::getSystemPath() to use routes first, I think that's going to get rid of quite a few _url() calls in way cleaner ways than this issue, especially in the page cache tags and rest tests. Also the WebTestBase changes I think are either very similar or actually copied from there.
Comment #95
mpdonadioJust so we have it, I took the patch from #82, applied to 9663c55, applied the interdiff from #84, and rebased against HEAD. There were a few manual merges. The patch is now about the same size.
I did not try to add in any of my changes from #90.
Comment #97
mpdonadioI'll defer to those above my pay grade about whether to postpone on #2350837: Convert most usages of EntityInterface::getSystemPath() to use routes, but a quick read of the patch does look like it would be a good idea. When I first looked at it, there was little intersection between the patches, but I think that has changed now.
However, between putting together Ikea shelves today, I picked away at the current patch and had some notes prepared that I don't want to lose...
ImageStylesPathAndUrlTest is failing on the non-clean URL test, because a clean URL is being generated. I think the problem is that ImageStyle::buildUrl() is using Url::fromUri('base://' ...) and is generating a clean URL because it is detecting that the system support clean URLs (could also be from the stream wrapper manager). Not sure what the proper way to override this is for testing purposes. I also didn't see any other similar cases in existing tests.
The REST tests are failing from a recursive router rebuild problem. As far as I can tell it is from when entity_test is enabled in the setUp. No clue why this happens. This fixes the problem, but I doubt it is a proper solution (or would be in scope of this issue):
Comment #99
dawehner@mpdonadio
What about the following idea: a) remove the intersections with the other critical b) remove the conversions which break at the moment
Just get this bit in. Further work / reviews for the other conversions could be then made more focussed ...
Comment #100
mpdonadioSounds like a plan. Added tag because #97 doesn't apply any more...
Comment #101
mpdonadioNot sure if this will buy us much.
And my notes in both.txt
That resulted in the attached as 2364157-101.patch.
Also attached a diff when I apply 2350837-57.files and 2364157-101.patch to see what the test results are.
Comment #104
mpdonadioBacked out change to ImagePath so that we can test unclean URLs.
Backed out change to BreadcrumbTest b/c I think #1799820: Breadcrumb doesn't get localized when displaying parent terms broke it.
I think all of the rest are recursive router rebuilds. I can't find what part of the patch is causing this, or how to fix it without the major hack from above.
Comment #106
mpdonadioI have a disconnect between my patch names and my git repo, so the last few patches above aren't ready to look at. Working on straightening all of this out.
Comment #107
mpdonadioThis should come up green, and be free of intersections with #2350837: Convert most usages of EntityInterface::getSystemPath() to use routes.
However, please see the attached trace.txt and look at the change to Drupal\rest\Plugin\Derivative\EntityDerivative::getDerivativeDefinitions. Without that hunk, there are several test failures due to recursive router rebuild detections.
Essentially, WebTestBase::setUp() eventually leads to a drupal_flush_all_caches() after the required modules have been installed. The end of that function has a router rebuild. While rebuilding the router, Drupal\rest\Plugin\Derivative\EntityDerivative tries to get a route (entity.entity_test_mulrev.canonical) from the RouteProvider. That has a RouteBuilder::rebuildIfNeeded() call in it, so we end up with a rebuild in a rebuild.
The attached patch is a quick hack to just show that preventing the recursive rebuild makes this patch pass. Questions:
Fix this in this issue, or a new issue?
Should the fix catch the exception? If I do this, I would make a RouteBuilderException which extends \RuntimeException so we have something proper to catch.
Or, should the fix just do
Or, and I missing something?
Comment #108
dawehnerSo the underyling problem is that REST module should not rely on routes in order to build routes (see #2281645: Make entity annotations use link templates instead of route names which has the foundations to solve that properly).
The current fix is, is to be able to get the route collection during the rebuild phase. It seems to be that we could fix with just not
assuming that the route is there all the time, see interdiff.
Comment #109
mpdonadioThat looks like it works. I expect this to be green.
Comment #110
mpdonadioComment #111
dawehnerLet's drop that again ...
Those could be an example of which we know the the actual route name, don't we?
Note: update.php is a route, so we should be able to link to it.
can you describe why we need this here?
Comment #112
mpdonadio#111-1,2,3 should be easy.
#111-4 has been in the patch since the 2364157-2.patch version. Do you recall why you added it? :) I'll yank it out.
Comment #113
dawehnerHA, maybe drop it and see whether it works, otherwise keep it in :)
Comment #114
mpdonadio#111:1-4 should be fixed. Wish I had remembered about the route debug info in the Console project earlier...
Comment #117
mpdonadioSearchPageOverrideTest and EntityResolverTest are failing because the try/catch that we removed were masking a problem.
The other failures were from #111-4: 'Some mandatory parameters are missing ("project_name") to generate a URL for route'
Comment #118
mpdonadioEntityResolverTest is still failing:
I don't see how the router is installed, is fully rebuilt, and the canonical route for entity_test_mulrev doesn't exist despite being in the entity definition.
Comment #119
mpdonadioActually, it looks like EntityTestRoutes::routes() doesn't set up canonical routes.
Comment #121
mpdonadioThis should come up green.
Added Needs issue summary update since we need to document what we aren't converting right now, and get followup issues made.
Comment #122
dawehnerIn case you have some time to fix this, here is a small nitpick.
Sorry for this nitpick :)
Comment #123
dawehnerAdded the list of remaining
_url()calls.Comment #124
aspilicious commentedQuoting myself from IRC
Comment #125
dawehner@aspilicious
So you want to introduce
Url::fromPath()? Not sure how this is related with this issue, ... we use it when we don't have routing available, like for things in REST which are not routes under the hood. Feel free to introduce an issue introducing just that.Comment #126
aspilicious commentedI tried before... But I'll try again... But Yeah not strictly related to this issue.
Comment #127
dawehnerThe documentation should clearly document when to use it and when to NOT abuse it.
Comment #128
mpdonadioThe rebase against 8.0.x did an automatic three-way merge, so technically this is a reroll + newline for #122. The interdiff is between my git branches after the rebase.
Comment #130
mpdonadioLets try this with an actual patch.
Comment #131
berdirThis will need a reroll after #2281645: Make entity annotations use link templates instead of route names, I suggest you wait until #2406439: Cleanup EntityDerivative and RouteBuilderInterface is committed as well, that should get rid of that recursive router rebuild business.
Comment #132
mpdonadioYeah, I was expecting that, and waiting on #2406439: Cleanup EntityDerivative and RouteBuilderInterface is probably a good idea to see if we can back out that workaround. I'm also hoping #2350837: Convert most usages of EntityInterface::getSystemPath() to use routes can get in, too, before I post another patch, just in case it introduces any problems.
Comment #133
dawehnerAlright, let's wait on the other RTBC patch.
Comment #134
mpdonadioFound a short time break to test this...
My reroll + a small adjustment for 2406439 is coming up green.
The reroll has two manual merges. Both keep HEAD. One essentially backs out our router rebuild workaround. The other is to use the path-style link annotation for entity_test_mulrev.
That + 2350837-95.patch (ie, the RBTC one) applies cleanly and also comes up green.
I'll unpostpone and post the proper patch tonight so people can begin reviewing again.
Comment #135
pwolanin commentedLooks like a lot of the base:// usages shouldn't be there - you don't know the route name?
Comment #136
tim.plunkettThis should use a route name, as per #73
This obviously can't.
There's a chicken and egg problem here, and I don't think you can use a route name for any of these rest paths.
Comment #137
dawehnerOh right we should use a route, but drop that silly comment above " // Simulate a typo in the URL to force a curl exception."
Well, its also just a PATH used just for the HAL respresentation and its linking internally. Its not something Drupal provides.
Comment #138
mpdonadioOK, latest patch based.
Rebased 130. Two conflicts. Kept HEAD for both. One essentially backs out our router rebuild workaround. The other is to use the path-style link annotation for entity_test_mulrev.
Interdiff is against the rebase. The change to NodeTranslationUITest brings it back to HEAD b/c #2350837: Convert most usages of EntityInterface::getSystemPath() to use routes now overlaps here. The other change is to add real canonical routes for the entity_test entity types (the test types invoke ->url() in a few tests, which were the cause of exceptions).
This should come up green. This + entity-get-system-path-2350837-102.patch also came up green in my test.
All uses of base:// seem to be necessary. Once this, and similar path/route related issues, get in, I will open a followup issue to audit core for base://, and either convert to route or document why base:// is needed in each case.
Comment #139
berdirAll the calls that are made to this method are valid route names, I believe this could be refactored to accept an Url object instead of a $path string and then just do $url->setAbsolute()->toString(), see my last patch in the getSystemPath() issue, a few similar refactorings.
I hate that we create those objects here by hand in a kernel test, but I guess that is not for this issue to change.
Looks like an unecessary change, nothing else in this file is changed, so there can't be anything using Url?
No "The " then. And even that doesn't really make sense. (that method does not return a URL string)
Maybe just "The right URL ..."?
There's an issue for this @todo that @larowlan is working on, you might want to check that affects this.
This is strange. I don't see why this shouldn't just call $entity->url() ?
Once getSystemPath() is in, you can just pass $url through here.
Noticed that another call called just 'update.php/results' here, toString() would be '/update.php/results', Which one is correct?
canonical pointing to the edit form? why do we need this, and why like this and not an _entity_view?
This is a route I think, in a test module.
Missing description on the @return, AFAIK, only $this does not need one.
What happens if this is called if the view has arguments?
This exception message not english is :)
Comment #140
mpdonadioI'll look at these, but a few quick comments.
8. The second argument to batch_process() is supposed to be a Url object.
9. This was to match the change in #2281645: Make entity annotations use link templates instead of route names where the annotation has the same path for canonical and edit form. The canonical route was needed to prevent an exception in a test, but I don't think it is used anywhere b/c it was just in a data structure.
Comment #141
berdir8. I meant the first argument, not the second :)
9. Strange. Have a look at entity.routing.yml, it has the canonical route, but only for entity_test, not the others. I suggest you move that into the class and make it generic but consistent with that.
Comment #142
berdirAlso, keep an eye on #2350509: Implement auto-route generation for all core entities and convert all of the core entities., that is doing the same now I think.
Comment #143
dawehnerFor now we don't support this. It is a little bit tricky to convert
ViewExecutable::getUrlto the logic to create url objects.Comment #144
mpdonadioOK, this should come up green
#139-1,4,6,10,11,13, done
#139-3, reverted file to HEAD, done
#139-5, checked with @larowlan on #2336247: Make Relation and Type domain configurable based on context and he said to leave this in this patch.
#139-7, added @todo
#138-8, the $finish_url in system_authorized_batch_process() comes from system_authorized_get_url(), which is authorize.php not update.php, so left this as-is
#138-9, I realized that I had duplicated that route (not sure when it came in). I reverted that file to HEAD.
#139-12, per #143, left as is
Comment #145
dawehnerTim asked that multiple times now. Are you sure this is needed here? There is a routing definition for this path:
Comment #146
mpdonadioCleared up some confusion on my end w/ FeedParserTest::testRedirectFeed(). There was a small manual merge needed when I rebased, so the interdiff is a `git diff` just against the file that I changed.
Comment #147
dawehnerI'm fine with this, as it is now.
Comment #148
naveenvalecha@mpdonadio,
Are we going to inroduce the Url::fromPath() that's why we are not going to remove the all calls ?
Updated the issue summary #121.
Added the beta changes section as well.
Not removing the tag right now as it need to create another follow up issues to convert remaining
_url()calls and also need to update the follow up issues as well.Comment #149
alexpottUnless we want a CR here then we should do
$batch_url->toString()here. Unfortunately, as far as I can see, thisredirect_callbackis completely unused, untested and undocumented so whilst it might be nice to just pass the Url object alone I think this is the best option.This all looks unrelated to me
Only for one test? (
TokenReplaceTest) Can't we just to this in the test?Comment #150
naveenvalechaRemoved the special characters from the html.
Yeah #149-2 will address with that because these are not related to this patch.
Comment #151
mpdonadioOK, I am postponing again on #2350837: Convert most usages of EntityInterface::getSystemPath() to use routes so we can get an accurate list of remaining _url() uses, and get the followups made.
#149:1,2 should be easy.
I am deferring to @dawehner on #149-3.
Comment #152
naveenvalecha1)Addressed the #149-2 that makes more sense and not related to this stuff.
The interdiff is not same as specified https://www.drupal.org/documentation/git/interdiff I accidently committed the changes in the same new local branch.
So I created a new branch and apply the #149 patch to it.and then commit the changes to it and then create the patch by
diff oldbranch new branchInstructions followed :
Is there any better option to do if accidently commit the changes in the same issue old branch ?
2)#149-4
Updated the issue summary with the function usages in call and as well in comments.
Will need to create the child issues.how should the follow ups be created ?
Should be 7 followups for different components ?
1)For core/inlcudes/common.inc
2)core/module/image
3)core/module/node
4)core/module/rest
5)core/module/simpletest
6)core/module/system
7)core/module/views
Comment #153
yesct commentedchanging to needs review so the bot will run.
will change it back.
about to update the beta evaluation.
---
you could have made the interdiff by git diff'ing the two branches. :) Next time.
Comment #154
yesct commentedupdated beta evaluation (and put it in the motivation, where Contributor task: https://www.drupal.org/contributor-tasks/update-allowed-beta says to put it, and so it doesn't get lost after the long list of usages)
Comment #155
yesct commentedComment #160
mpdonadioThe change to update_test.routing.yml is needed.
This patch includes #149-1, #149-2, and will come up green.
Will postpone when TestBot is done.
Comment #161
mpdonadioBack to Postponed on #2350837: Convert most usages of EntityInterface::getSystemPath() to use routes, as that removes some _url() calls and (unfortunately) introduces a few more (three last time I counted). When we get the final list, I will triage them into groups, and have a followup for each to keep things manageable. I anticipate one for
However, I think the first two in this list may need to be postponed on #2405551: Add a method to support UIs where users enter paths instead of route names and other valid use cases.
I am deferring to @dawehner on #149-3 to weigh in before we make the (hopefully) final version of this patch, but I think we will want this method in ViewExecutable in the long term, as I think we will probably want/need it for some of the remaining routing/menu issues.
Comment #162
berdir#2350837: Convert most usages of EntityInterface::getSystemPath() to use routes got in!
Which means that needs needs a reroll for sure and then we need to check if we really got all _url() calls.
Comment #163
berdirI'll do a reroll of this.
Comment #164
berdirActually, the patch applies, but we still have 30 calls to _url().
Comment #166
borisson_Comment #167
borisson_Follow up issues should be created for the remaining _url calls.
Comment #168
mpdonadioYeah, see #161. When I get a chance later this morning, I will look at the remaining usages, update the issue summary, and get the followups made.
The current patch does needs review, though, and input about `ViewExecutable::getUrl()` should stay there be moved to the test.
Comment #169
mpdonadioComment #170
mpdonadioI updated the issue summary to the best of my ability, and created followup issues.
The change to update_test.routing.yml was needed. That remains in the current patch.
@dawehner discussed this in IRC, and while `ViewExecutable::getUrl()` is currently only used in test, the functionality is in line with what this patch does and we will need this down the road for non-test code.
Comment #171
yesct commentedso... this is a meta and will not have a patch? wait .. #170 says there will be a patch for update_test.routing.yml so... what should the title be?
How is this different from #2409233: Remove remaining _url() calls not covered by other issues?
Comment #172
mpdonadioThis is not a meta issue. #160 has the latest patch. This morphed from a "replace all" to "replace most, with followup issues" to account for some very specific and difficult problems with getting rid of _url(), and to account for new uses of _url() that have crept in, and account for how other patches have changed a bit over time. Doing everything in a single patch has become too difficult.
This issue now gets rid of most uses of _url(). The three followups issues get rid of the rest. The Views and Image followups are for two difficult cases. The third, 9209233, is to get rid of the stragglers.
Comment #173
berdirI'm not sure about all those follow-ups. How is #2409233: Remove remaining _url() calls not covered by other issues different from this issue, for example?
Closing one critical just to end up with 3 additional ones doesn't really help us, especially if it is not one specific usage. I can see an argument for getting a part of the patch in to to make reviews of the remaining stuff easier, but maybe we can commit that here and just keep the issue going. Or we can open a separate issue to get those in. Not sure.
I will try to take a look at the remaining cases today, if I don't get distracted too much.
Comment #174
berdirThat said, I see the point of the views follow-up, because that needs #2404603: Add proper support for Url objects in FieldPluginBase::renderAsLink(), so we can remove EntityInterface::getSystemPath(), but maybe we can fix both _url() and getSystemPath() calls in that same issue instead of two?
Comment #175
berdirOne down, this fixes the image style URL. Maybe we want to do more cleanup there, and extract the common logic there into RequestContext or so, I copied this from generateFromPath(). This would also partially at least solve system_js_alter().
Comment #177
berdirFixed the installer and updated rest tests. Was debugging this for a long time because I didn't clone the URL at first.
Comment #179
berdirStupid typo.
Note: For the base:// added in rest tests, we could add a httpRequestWithBasePath() or something as a wrapper, but I think an easier to use helper method is being worked on anyway.
Comment #181
berdirOk, fixed some tests, tried to update system_js_alter(), not exactly sure if this is going to work, we'll see.
Also updated a lot of stale documentation references.
As far as I can see, we now have three cases left:
- page cache tags, we have an issue for this. Should not be too hard to do, but might result in quite some changes: #2372899: PageCacheTagsTestBase should use Url objects, so that might be a useful follow-up. Or we could just bake in a Url::fromUri() there.
- Breadcrumbs.. similar but worse, dozens of hardcoded path calls. Easiest fix might be a few Url::fromUri() call there.
- Views.. well, yeah.
- ( few left referenced inside places like _l(), that should go away themself as well.
Comment #183
berdirFixing test fails.
I also posted a patch to #2372899: PageCacheTagsTestBase should use Url objects.
Comment #185
mpdonadioSimple fix to DeleteTest for the entity that does not exist, and checking for 405 when trying to delete a resource which is not REST API enabled (405 is Method Not Allowed).
Comment #186
berdirHere's an attempt at using Url::fromUri() instead of generateFromPath().
I updated the _url() calls in the menu tests, and I also added back support for system paths to rest tests, after thinking about it, I don't see anything wrong with that, given that we continue to support it in the same way in drupalGet(). I added a new helper method called buildUrl(), not too happy about that, maybe builtAbsoluteUrl(), but the problem is that we already have getAbsoluteUrl(), which is now used by buildUrl(). Any suggestions on the naming there?
Comment #188
mpdonadioREST tests. Was going to make this suggestion and add it, but didn't see you in IRC at the time.
How about buildTestUrl() or buildPathforTest()? Something that suggests that this code just for testing purposes and not to be used as sample code? Could this also replace a lot of the `Url::fromUri('base:://' . $path)->toString()` that are all over the tests, maybe with a parameter to enable (or disable) the absolute path?
Accidentally added $path to the ->toString() call.
Comment #189
berdirHaha, painfully stupid. Changed everything 3 times, only to end up with base::// everywhere.
Comment #190
berdirCrossposted with the review. Fixed the additional $path there.
Comment #193
berdirOk, looks like fromUri() doesn't work, it can't handle an empty string for example (= frontpage). I think we nee to go back to generatorFromPath() unless @dawehner has an idea?
Comment #194
dawehnerI'd be fine with as it is, given that it is quite some progress.
Comment #195
mpdonadioUpdated IS to remove outdated / unneeded child issues.
Comment #196
berdirReverted buildUrl() back to use the url generator.
@dawehner: Ok. But all the other changes that I made in those patches are still useful, it is hopefully just this part that is hard.
Comment #198
mpdonadioAdjusted some logic in AssertBreadcrumbTrait.
Comment #199
jibranThis is close just few minor points left.
We can do this in one line.
According to the function doc of batch_process 1st @param is path we are passind Url object here. Either docs are wrong or this is wrong.
and performance here is OR and performance is critical here.
Please add comments here.
Please add @see to LinkManager class.
more then 8 chars.
doesn't make sense is it for or from?
Comment #200
pcambraPlain reroll
Comment #201
pcambraFixed, 1, 3, 5 & 6 from #199.
Regarding 2:
Added a Url|string in the docs as _batch_finished() is the only place where 'batch_redirect' is used, and it handles both Urls and paths.
4 and 7 are still to do.
Comment #204
pcambraSeems like this one has affected here: #784626: Default all JS to the footer, allow asset libraries to force their JS to the header
Also related? #1547376: Allow url() or some other function to return individual components of an outbound URL
The fail is happening here:
Comment #207
mpdonadioThe exception leads to the real culprit. You need the router schema and to rebuild the route tables.
I wonder if we should add these two lines to KernelTestBase::setUp and WebTestBase::setUp, and remove from the individual tests? This is bound to happen in the future.
Didn't look at anything else; just fixed that test (AttachedAssetsTest came up green locally).
Comment #208
dawehnerIMHO, 100% pointless. There is a new statement, we know exactly which class we talk about already.
Comment #209
mpdonadioI'll touchup the last few things and get a patch posted tonight.
Any thoughts on adding
to KernelTestBase::setUp and WebTestBase::setUp to prevent the router exceptions in new tests that get added in the future that use Url()::fromRoute()?
Comment #210
berdirNot related to this issue. Web tests have that anyway, it would only be kernel tests that would need it. Agreed that it would be useful there, but not sure about installing the table by default, we try to make kernel tests as fast as possible, with some DX costs for installing tables and so on.
Comment #211
mpdonadio#199-4 is done. Not sure if someone has a better way to explain this.
I think the language in #199-7 is fine as-is.
#208 is done.
Also did a search for "Url::fromUri('base://" and all of the uses we introduce look legit.
Comment #212
dawehnerMaybe we can finally nail it down.
Good catches, this is not about PHP url()
It would be great to describe why we need to add it here.
... Please let's use
Drupal\Core\UrlCan someone explain why the behaviour changed?
Comment #213
berdir4. Because the old path was bogus. The test was supposed to test that it is no longer possible to access that resource after it was disabled, but it used the old path with the entity/ prefix, which is always 404, resource enabled or not :)
Comment #214
dawehner@Berdir
Yeah @mpdonadio explained it me in person.
Comment #215
mpdonadio#212-2, made comment better
#212-3, was unused, so removed
#212-4, this is the proper behaious. The user exists, but the DELETE action doesn't exist for it.
Also added a proper Url() object per a verbal comment.
Comment #216
dawehnerLet's get crazy tonight
Comment #217
webchickYou know what? Let's do this. We may find we have more clean-up to do here, but it'll be much easier to do in smaller, targeted follow-up issues.
Committed and pushed to 8.0.x. YEAH! Awesome work, everyone.