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
The code in PluginBase::viewsTokenReplace() replaces $twig_tokens[$top]
on every loop, if multiple tokens have the same $top, only the last actually ends up in the array.
Proposed resolution
Merge the tokens together instead of overwriting.
Remaining tasks
User interface changes
API changes
Data model changes
Why this should be an RC target
From #5:
Trivial fix with test coverage that really shouldn't break anything, so maybe we can get it in before 8.0.0?
Comment | File | Size | Author |
---|---|---|---|
#6 | views-token-2591125-5.patch | 1.75 KB | Berdir |
#5 | views-token-2591125-5-tests-only.patch | 1.03 KB | Berdir |
#2 | views-token-2591125-2.patch | 764 bytes | Berdir |
Comments
Comment #2
BerdirComment #3
Jaesin CreditAttribution: Jaesin at Chapter Three commentedI just wrote basically the same patch:
Comment #4
LendudeStill needs tests, so back to needs work.
Comment #5
BerdirLets add them, then.
Trivial fix with test coverage that really shouldn't break anything, so maybe we can get it in before 8.0.0?
Comment #6
BerdirWeird double post is weird
Comment #8
Jaesin CreditAttribution: Jaesin at Chapter Three commentedThe easiest to test this is to create a view with two "nid" contextual filters and a path like: "test-view/%/%". Maybe disable caching for the view for good measure.
Add a "No results behavior" of "Global: Text area" with the following content:
You will notice that if you go to the url: "test-view/12345/54321" without the corresponding nodes existing, you will get an output like:
After applying the patch in #6 , you should see:
as expected.
Comment #9
xjmAdding the RC target reasoning to the summary.
Comment #11
tim.plunkettWent to RTBC this, see I'm behind the times. +1 from me :)
Comment #12
effulgentsia CreditAttribution: effulgentsia at Acquia commentedI discussed this with @xjm, and we agreed that "tokens are broken in Views" qualifies as sufficiently high impact and that the patch qualifies as sufficiently low disruption, so it's good as an RC target per https://www.drupal.org/core/d8-allowed-changes#rc.
Comment #14
xjmCommitted and pushed to 8.0.x. Thanks for the fix! Thanks also @Jaesin for the excellent testing steps.