Closed (outdated)
Project:
Drupal core
Version:
11.x-dev
Component:
views.module
Priority:
Normal
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
14 Feb 2015 at 01:35 UTC
Updated:
4 Nov 2025 at 15:13 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
mpdonadioHappened to have this file open. What about something like this?
See if the path is routable with PathValidator, otherwise use it as-is? This is kinda for discussion, as I can't 100% remember which of those variables has the path w/o the scheme.
Comment #3
mpdonadioThis patch fixes the problem described above when I reproduced the situation in the summary (import .views.view.test_dropbutton.yml, and enable Language).
However, we need to add coverage to FieldPluginBaseTest to cover this situation.
Comment #4
mpdonadioWe may want to wait for #2426447: Views no longer supports {{ something }} as twig placeholder for a path, only {{something}} to get in before working on the tests, as that issue adds coverage for tokenized paths, which we can then build off of.
Comment #5
mpdonadioThis test kinda feels like cheating, but it passes locally for me.
Comment #6
mpdonadioMinor cleanup to fix some coding standard things.
Comment #7
wim leersSome advanced trickery going on here! :D
s/otherise/otherwise/
s/is/it/
:)
Wow — we're being brave — relying on PHP's operator precedence :D
Wow!
I think this can use some additional comments. At least speaking for myself, this looks too confusing/black magic-ish.
(I kind of understand why it's necessary given the IS, but future readers of this code will say "lolwut" in unison I think :D)
Comment #8
mpdonadioThanks for the review Wim.
#1 taken care of by the rewrite in #3.
I can assure you that #2 was by accident. I don't have the operator precedence chart memorized :) Added parens to make it more readable.
Added big comment block to account for #3.
Also attached screenshot showing a view-source of the test-dropbutton view that shows the language prefix on the custom text link, and that it matches the path prefix on all the other links in that row.
Comment #9
wim leers:D
Why "may"? Isn't this *always* the case in case of a token replacement?
s/portion/component/
But this is not actually extracting the path component, it also includes querystring and fragment, if any.
So URI reference is probably more accurate.
OTOH, maybe just
parse_url()the path component only? That'd be clearer.Comment #10
mpdonadio#9-1, no. views.view.files.yml has a path defined for a page display with a Twig token in it (that is the view path that started the chain reaction of Url() related issues). Right before token replacement, the URI string in FieldPluginBase::renderAsLink is 'route:view.files.page_2;arg_0={{fid}}', and ends up being treated as a routable URI through the $final_url logic (I double checked this with debug).
#9-2. Took another stab at that comment, and changed the logic to use parse_url(); that will be less fragile.
Comment #11
fabianx commentedThe following is simpler and should do the same:
All that said, views should not hide this and 'cheat'.
While still strongly discouraged, there seems to be a need for a generic helper function to turn a path - potentially from base: to a full path - even in core.
Display Suite has the same problem. (with the exact same use case of using tokens)
And panels will probably, too.
We surely don't want to force all of them to find and re-implement this magic code.
Comment #12
mpdonadioThanks for the review @Fabianx; that will likely read better. I'll double check it when I can locate my development laptop...
`Url::fromUserInput()` will take a path and run the pathValidator on it to get a routable Url object if possible via `Url::fromUserPathUri()` (see #2426181: Add a Url::fromUserInput() wrapper method for generating URLs from user-entered paths). The difference here is that as part of #2418139: Add a toUriString method to Url class and add a route: scheme and #2404603: Add proper support for Url objects in FieldPluginBase::renderAsLink(), so we can remove EntityInterface::getSystemPath(), `FieldPluginBase::renderAsLink()` works with the URI string and not a path, since token replacement may need to happen on on the route arguments and/or query options and not just the path component.
I am setting this back to Needs Work, though, as I want to see if the final version of #2426181: Add a Url::fromUserInput() wrapper method for generating URLs from user-entered paths will require any logic changes here.
Comment #13
mpdonadioSimplified some of the logic per #11.
#2426181: Add a Url::fromUserInput() wrapper method for generating URLs from user-entered paths didn't affect this one way or another.
Comment #14
mpdonadioAdded a test to FieldDropButtonTest to reproduce the one described in the issue summary.
Comment #16
fabianx commentedPatch looks good to me. Thanks for the explanation, has a test, therefore RTBC.
Comment #17
dawehnerMh I try to understand it. So it would have been possible that we end up with base:node/1 right? In that case running the path validator is fine, but the documentation kinda talks about path processing. In that case the UnroutedUrlAssembler has a flag to force path processing to run.
Comment #18
mpdonadio@dawehner, in this view, we are getting `base:node/1` as a URI. What would you have the documentation say for this?
Comment #19
xjmComment #20
mpdonadioUpdated IS; added Beta eval.
Comment #21
alexpottSo should we be using the
UnroutedUrlAssemblerhere?Comment #22
mpdonadioI am not sure why we would want UnroutedUrlAssembler, as that more or less is the problem.
If we are ending up with 'base:node/1' as the final URI after token replacement, then we have a valid, routable path and should pass a routable Url() object to the link generator. Otherwise 'node/1' gets treated as an unrouted path, and gets sent off to the UnroutedUrlAssembler().
?
Comment #23
dawehnerI'm curious whether we should just expand the options to set ['path_processing'] = TRUE. Don't we then ge the basic same result?
Comment #24
mpdonadioOK, here is the simple idea from #23. The patch is a clean checkout from HEAD with that option added + the new test. Passes locally for me.
Comment #26
mpdonadioLet's pretend that didn't happen.
Comment #27
dawehnerI kinda like the way how it solved now, but on the other hand yeah the unbound URL assembler was never intended to always generate path aliases.
Comment #28
dawehnerI kinda like the way how it solved now, but on the other hand yeah the unbound URL assembler was never intended to always generate path aliases.
Comment #30
mpdonadioBlerg. I forgot about all of the mocking that is needed in FieldPluginBaseTest, which would need to be addressed. So, which option do we want, real routes or unrouted paths + outbound processing? If the later, I'll fix the unit test.
Comment #34
gábor hojtsyComment #35
gábor hojtsyNo work unfortunately for a long time, removing sprint tag :/
Comment #36
mpdonadioIf someone above my pay grade choose a direction (unrouted w/ path processing in #26 vs routes in #14), I'll wrap this up.
Personally, I think #14 is the best option.
Comment #37
kikoalonsob commentedFYI, Error still occurs in RC2.
Comment #38
wim leersIs this still broken?
Comment #39
mpdonadioQuick hand re-roll of test-only patch to see what happens, but we should check that it is still a valid test (mainly, that the class names haven't changed).
Comment #41
mpdonadioLooks like this is still an issue. Existing test passes. New one fails.
We need to pick
- #14: use the path validator to convert the post-token / post-processed path into a URL object, which will then get all of the related URL goodness
- #26: update the url generation in view plugin so that outbound path processing runs, regardless of whether the path is routable or not
Personally, I think the approach is #14 is better.
Comment #42
jibranI think we should prefer #26 as per @dawehner's choice.
Comment #43
jonhattanBoth #14 (use path validator) and #26 (run outbound path processing) are outdated. Rerrolled #26.
Comment #44
mpdonadioThis is a bug, so this should be 8.0.x eligible. I was going to work on this at DCNJ, esp since @dawehner will be there, too.
Comment #46
mpdonadioLooking at this now. Concerned that FieldDropButtonTest fails now, which should be fixed by the patch.
Comment #47
mpdonadioBlocked on #2657932: Url::toUriString() doesn't work properly for user input.
Comment #61
quietone commentedThere has been no activity here for 9 years.
Can someone confirm that this is still a proeblem?
If we don't receive additional information to help with the issue, it may be closed after three months.
Thanks!
Comment #62
smustgrave commentedWanted to bump this one more time
Comment #63
smustgrave commentedSince there's been no follow up going to close out. If still an issue please re-open