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
In order to be able to get rid of the _l
call in FieldPluginBase::renderAsLink
it needs really proper support
for url objects, not the half-baked which is currently the case.
Proposed resolution
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#93 | 2404603-93.patch | 47.54 KB | dawehner |
#93 | interdiff.txt | 1.01 KB | dawehner |
#91 | interdiff-85-91.txt | 2.31 KB | mpdonadio |
#91 | add_proper_support_for-2404603-91.patch | 47.29 KB | mpdonadio |
#86 | interdiff-82-85.txt | 604 bytes | mpdonadio |
Comments
Comment #1
Wim LeersI hope this clarification is correct?
Comment #2
idebr CreditAttribution: idebr commentedComment #3
dawehnerThis is at least major.
Comment #4
dawehnerSome start of work with writing a couple of tests, they aren't done yet.
Comment #5
dawehnerStripped out the other patch and worked a bit on it.
Comment #7
mpdonadioComment #8
mpdonadioRe-roll.
Comment #9
mpdonadioComment #11
webchickIf #2410499-3: Remove remaining _l() calls in Views is true, then this blocks #2343669: Remove _l() and _url(), so escalating to critical, and blocker.
Comment #12
webchickComment #13
mpdonadioProbably still needs some work...
Comment #15
mpdonadioReal patch. Probably still needs some work...
Comment #16
dawehnerSo the next steps would be to a) convert the manually sets 'paths' in all the handlers and b) for the other cases use user-path:
Comment #17
dawehnerSo yeah, let's be honest ... given the next steps are needed.
Comment #18
mpdonadioWorking on replumbing w/ URL objects.
Comment #19
mpdonadioWork is progress to see what TestBot says.
Comment #21
mpdonadioFixed some routes names and link template names.
Comment #22
mpdonadioComment #24
dawehnerNote:
$entity->getUrl()
does not exist.As talked about, let's try to drop it.
Nitpick: Afaik it should be "Contains \" ...
docs ...
@covers annotations would be nice.
Comment #25
mpdonadioThis is likely blocked on #2418139: Add a toUriString method to Url class and add a route: scheme. The problem has to do with needing the ability to do token replacement on paths, and currently ending up with the base getting added twice. So, we need the ability to token replace on the URI before we convert it to a URL.
I am still working on this, though, so keeping it assigned to myself.
Comment #26
mpdonadioComment #27
larowlanBlocker is in
Comment #28
webchickJust tidying up some metadata.
Comment #29
larowlanThat night the children slept, whilst dreams of diffs danced through their head.
Would the patch fairy visit them in the night?
Comment #30
larowlankicking it further along, down to 4 fails in the unit test.
really bizarre how we create a url object more than once in the ::renderLink method - I think there is real scope to simplify there once we have passing unit-tests. Feels especially weird that we keep dropping it back to a string path and re-parse that instead of sticking to the Url object.
2hrs plus of staring at this is enough, more tomorrow.
Comment #32
larowlanmore stuff
we're going string -> url ->string -> url too much
Comment #34
mpdonadioTry to find me on IRC today. I was still working on that. We had passing unit tests on this before the last round of work on it.
Comment #35
dawehnerYeah I'm not convinced that altering the shit out of things using the base path is the best idea :)
Comment #36
mpdonadioAssigning myself. Will work on it, update issue summary, etc, with what we discussed this weekend and will post something by EOD (I'm UTC-5).
Comment #37
larowlanHi @mpdonadio
I'm GMT+10 and was pointed at this issue by webchick and pwolanin when we did a NJ baton pass. Angie and I asked if you were still working on it in #drupal-nj and were told you were asleep. Didn't realize you had a partial patch, sorry. Feel free to ignore my changes, Lee
Comment #38
mpdonadioNo worries, I should have updated the proposed resolution to show how we were going to use #2418139: Add a toUriString method to Url class and add a route: scheme to hopefully make this cleaner.
Comment #39
mpdonadio#32 Looked like a better starting point than my WIP (esp w/ the necessary changes to the unit test), so I hand merged a few changes in. This is mainly to see what testbot says, and to hand it off.
If this somehow comes up green, the next step would be to see if we can optimize the Url -> string -> Url -> string, which may only be possible for routed Urls. Perhaps, in this case we can do the token replacement on the route parameters and options arrays, and then bypass one stringization step.
Comment #41
larowlanpoking again
Comment #42
larowlanthe user-path no longer needed because toUriString() includes that
to do:
* path processor for language handling (or we add a kernel test for those)
* some fragment and query elements being lost, not sure if those are in views or in toUrlString()
Comment #44
dawehnerJust some driveby nitpicks.
An @see to ViewExecutable::getUrl() would be nice.
... this certainly belongs there.
nitpick: 2 empty lines
Comment #45
mpdonadioAah, #44-2 closes the @defgroup at the top (missed that), so it should probably read
Comment #46
dawehner@mpdonadio
Yeah, i guess so.
Comment #47
mpdonadioI'll see if I can make any forward progress on this today during breaks. I will unassign myself and post my WIP.
Comment #48
mpdonadioTagging out on this for the day. #44 is addressed. Didn't have time to look at the fails, so this isn't worth a TestBot run.
Comment #49
larowlankicking along
this should leave just the phpunit fails
Comment #51
mpdonadioTag, I'm it. Will post my work by end of day.
Comment #52
mpdonadioExpecting one fail in FieldPluginBaseTest::testRenderAsLinkWithPathAndOptions() with this.
I am not sure why, but the outbound path processor for prepending the language isn't running for the unrouted URL assembler. It does work for routed ones.
I am not sure if this is a mocking problem, a container problem (eg, a missing service), or something else. Oddly, I can't find a unit test that does language prefixing for an example. I suspect that PathProcessorLanguage needs to be wired up to the unrouted URL assembler, but I kept having problems with this and ran out of time today...
Comment #60
mpdonadioI edited the wrong file in #48 and this also removes a test annotation.
Comment #62
dawehnerI hope its fine to skip the language test, see interdiff.
Comment #64
larowlan+1 from me, we test a lot of this in an integration test in Drupal\views\Tests\Handler\FieldWebTest, if we need language, we can add it there
Could be the fails are related to this?
Comment #65
dawehnerWell ...
Comment #67
RavindraSingh CreditAttribution: RavindraSingh commentedAdded
$alter['url'] = CoreUrl::fromUri('user-path:/' . ltrim($path, '/'))->toString();
Assuming this can be an blocker on previous patches
Comment #68
RavindraSingh CreditAttribution: RavindraSingh commentedComment #69
RavindraSingh CreditAttribution: RavindraSingh commentedSeems some size issue in my patch will add other things as well.
Comment #72
dawehner@RavindraSingh
The url here is not considered as string, so converting it, fails everywhere :)
Also, ..., please use git
apply --index
to apply your patches, because otherwise you miss new files.Fixed the failures ... and cleaned up the tests a bit.
Comment #73
RavindraSingh CreditAttribution: RavindraSingh commented+1 for your submission. Can we remove no of white lines and optimize some code while assigning values. like
can be
I am not sure if it is required here.
Comment #74
mpdonadioGREEN! Awesome.
This needs a few pairs of eyes looking at the tests to double check that they are doing what we think they are.
FieldPluginBaseTest::providerTestRenderAsLinkWithUrlAndOptions() could potentially use some cleanup, but that data provider was rather tricky to get right.
@RavindraSingh, thanks for trying to help move this forward. Also, make sure you post an interdiff if your work so everyone can see what has changed. Personally, I do the git-branch-per-patch method, as I tend to do small commits on complicated issues, so this helps in other ways for me, too.
Comment #75
YesCT CreditAttribution: YesCT commented@RavindraSingh regarding the optimization question in #73,
we cannot do that in this issue. We only want to change the lines we need to do this issue,
and there are lines building that array that do not need to change.
about the white lines, I looked through the patch and they all look appropriate.
Some are required by our standards, and some are added for readability.
As long as there are not multiple white lines, we are probably ok.
https://www.drupal.org/coding-standards#indenting
https://www.drupal.org/node/608152#indenting
Comment #76
RavindraSingh CreditAttribution: RavindraSingh commentedThat sounds good for me. I have reviewed the patch seems fine to me.
great job by everyone this long long thread. Moving it to RTBC .
Comment #77
Wim LeersShouldn't this be
delete-form
?cancel-form
The comment feels misleading/wrong. It feels like we should say that we convert
$alter['path']
to auser-path
URI. And perhaps that theUrl
class takes care of access checking. (Not sanitization.)Missing
{@inheritdoc}
.This comment can be deleted; it's poorly written and doesn't add anything.
s/Set ups/Sets up/
s/url/URL/
s/setup/setUp/
Comment #78
dawehnerThank you wim, working on fixing these points.
Comment #79
mpdonadioI'll take care of #77 later today (I wanted to look at this in PhpStorm anyway), but further reviews appreciated. Also very curious why #1 and #2 weren't caught by tests? #2 is really wrong since is calls url() and not urlInfo().
I am nearly sure the comment on #3 is leftover from the old code where _url() was called and this was a proper comment.
Comment #80
mpdonadioCrosspost. Will let @dawehner take care of this.
Comment #81
dawehnerGood catches!
Right, this was a comment targeting code, which has been temporarily part of the patch.
Fixed the other points as well
Comment #82
dawehnerI would bet with you that not everything is tested in views :)
Comment #83
dawehner@mpdonadio
You have the honor :)
Comment #86
mpdonadioThis just fixes another link annotation URL. I did a search and eyeballed the others, and they look OK.
I'm just confused as I thought I remembered seeing tests for these when I was working on the big _url() issue, but it looks like the comment list is still code and not a view, and the user list view doesn't have that link directly on it in each row. I get to them when I can, but it may be a few days.
Comment #87
dawehnerYeah this is sadly true. This hopefully changes with #1986606: Convert the comments administration screen to a view
The points of wim got addressed so back to RTBC, IMHO.
Comment #88
alexpottNot sure how this works. I can't find an approve link template.
huh?
Comment #89
mpdonadioI'll fix #88-1, and double check the need for #2 and explain it more better in the comment (I wrote that hunk). I'll probably do both later today.
Comment #90
mpdonadioNote that if #2417567: Rename user-path: scheme to internal: lands before this, the patch will need to be rerolled to take into account the explicit Url::fromUri('user-path') calls. However, I have Alex's feedback addressed w/ a green patch and will post tonight (the second point requires a bit of explanation that I don't have time for right now).
Comment #91
mpdonadioTL;DR, #88 is addressed with this patch.
#1, yeah no annotation; converted to fromRoute().
#2 need explanation. FieldPluginBase::renderAsLink() calls viewsTokenReplace() a whole bunch of times for token replacement. There is a system view in views.view.files.yml, view.files.page_2, that has an path defined with an segment that is actually a Twig token. This quirk is what led to the ::toUriString() issue...
Url::toUriString() uses UrlHelper::buildQuery() internally to build up the argument list for routes. That, uses rawurlencode(). The net result is that
So, we needed to decode those escaped values in order to token replacement. Instead of doing a total decode, we just string replaced those two cases. At the time, we thought doing this in viewsTokenReplace() for all tokens was best, but moving this just to the token replacement for paths probably is best (which is what this patch does).
\Drupal\file\Tests\FileListingTest is where we noticed this problem.
Comment #92
dawehner@mpdonadio
Do you mind updating the documentation with this example? I think this would make it more clear, what is going on here
Filed a follow up to increase the test coverage: #2424129: [Meta] Ensure that each handler in views has test coverage.
Comment #93
dawehnerLet's quickly adapt the documentation and move it back to RTBC.
Comment #94
alexpottThis issue addresses a critical bug and is allowed per https://www.drupal.org/core/beta-changes. Committed 7b5e5a9 and pushed to 8.0.x. Thanks!
I re-flowed the comment on commit.
Comment #96
BerdirThis introduced a small regression for twig placeholders, please review #2426447: Views no longer supports {{ something }} as twig placeholder for a path, only {{something}}
Comment #98
dwwNote: this issue / patch seems to have broken all the transformation options in renderAsLink() when the path you're trying to link to happens to be a route. See #2645954-26: Views output field as a custom link options all ignored if path is routed for more. Anyone who knows more about WTF is going on with this code is hereby invited to comment on / shred my latest patch there. But it does work. ;)
Thanks,
-Derek