Draft revisions of content entities with HTML Title enabled display latest published title incorrectly

Created on 8 October 2021, over 3 years ago
Updated 4 February 2024, 11 months ago

Problem/Motivation

When viewing a Draft revision of a content entity on its "Latest version" tab (eg node/X/latest), the page incorrectly displays the latest Published revision as the page title, as used by the Page Title block.

Steps to reproduce

  1. Install core "standard" profile
  2. Install html_title module 8.x-1.3
  3. Enable HTML Title and Content Moderation modules
  4. Configure the Editorial workflow to apply to the Article content type (admin/config/workflow/workflows/manage/editorial)
  5. Create an Article node (node/add/article), give it the title Original Title, enter Original body in the body field, and save a Published revision.
  6. Edit the same node, and change the title to Draft Title, change the body to Draft body, then save a new Draft revision.
  7. Observe that you are on the "Latest version" tab (node/1/latest), the body of the node correctly displays Draft body, but the title displayed is Original title, whereas we should see Draft Title.

Proposed resolution

I tracked this bug down to the way the node is loaded in HTML Title's hook_preprocess_page_title() implementation, and have a working fix I'll share shortly. The crux seems to be the difference between calling

RouteMatch::getRawParameter('node')

to get a `nid` to subsequently load the node, and calling

RouteMatch::getParameter('node')

, which returns an already-loaded Node object of the correct draft revision, and thus we get the appropriate title. Presumably we would need to explicitly check for and request the appropriate revision when loading the node from its nid, but fortunately the getParameter() handles this for us.

Remaining tasks

  • Create an issue fork and submit a Merge Request
  • Write test coverage for this fix
  • Review and validate the fix
  • Commit and merge :)

User interface changes

The title of draft nodes on the Latest version tab will display the correct title.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada spiderman Halifax, NS

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024