Problem/Motivation
The start_link field on courses builds the lms_start_link block for the current user when it is rendered through an entity view display (lms_component_formatter) or Layout Builder. The block carries the user cache context, which bubbles to the course render array. Any page showing the field, such as a course page or a listing built from view modes, is then “UNCACHEABLE (poor cacheability)” in the Dynamic Page Cache for authenticated users. #3619694: lms_start_link block should use a lazy builder instead of being rendered directly fixed this for the Views course card row and the block itself, but not the field’s own render path.
Proposed resolution
Make StartLinkFieldItemList::view() return a #lazy_builder with #create_placeholder => TRUE, built by a trusted static callback StartLinkFieldItemList::lazyBuild($course_id). Only the link varies per user and the rest of the display stays cacheable. CourseCardRow now uses the field’s placeholder; CourseCardRow::buildStartLink() is kept for placeholders already in the render cache.
Tests
Kernel test CourseStartLinkTest::testStartLinkFieldIsPlaceholdered renders a course with start_link in its display and asserts the user context does not bubble and one placeholder remains. After the placeholder is replaced, it asserts the link is rendered.
Issue fork lms-3631356
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
graber commentedMerged, thank you!