Steps to reproduce:
1. Create a view
2. Add a "REST export" display
3. Select Format = Serializer and Show = Fields
4. Add a "Global: View result counter" field
When you check view results you will see counter field's value as {{ counter }}
Proposed solution:
Use render and postRender functions instead of advancedRender at https://git.drupalcode.org/project/drupal/blob/8.8.x/core/modules/rest/s...
This will allow for uncacheable fields in row level to replace placeholder by the correct value as described in
https://git.drupalcode.org/project/drupal/blob/8.8.x/core/modules/views/...
Comment | File | Size | Author |
---|---|---|---|
#6 | interdiff-4-6.txt | 8.68 KB | piggito |
#6 | 3063180-6.patch | 8.83 KB | piggito |
#6 | 3063180-6-test-only.patch | 7.93 KB | piggito |
Comments
Comment #2
piggito CreditAttribution: piggito as a volunteer and at Skilld commentedComment #4
piggito CreditAttribution: piggito as a volunteer and at Skilld commentedTrying to fix tests, new test for scenario in issue description still pending.
Comment #5
andypostIt miss unit test
Comment #6
piggito CreditAttribution: piggito as a volunteer and at Skilld commentedI'm now including a patch introducing a new "FieldCounterTest" to proof the failing scenario described in issue summary.
Also, attaching the patch in 4 + test + an additional comment about usage of advancedRender
Comment #8
andypostLooks great to go
Comment #9
Wim LeersLooks good!
Comment #10
catchCommitted 06d2de1 and pushed to 8.8.x. Thanks!
Comment #13
SebaZ CreditAttribution: SebaZ commentedpatch #14 from Fix for global view counter works great for this issue. For me it should be fixed in core. You can use mentioned patch or just make your own plugin view field as a clone of a core Counter with change in
::render()
methodPatch #6 https://www.drupal.org/project/drupal/issues/3063180#comment-13156215 do almost the same, calling
::postRender()
method which do what::render()
should do.