"Content item" block generates PHP notice with view modes that have links

Created on 30 April 2024, 7 months ago
Updated 16 May 2024, 6 months ago

When rendering a "Content item" block with a view mode that has links, this PHP notice is generated:

Deprecated function: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\node\NodeViewBuilder::buildLinks() (line 132 of /code/web/core/modules/node/src/NodeViewBuilder.php) 

We also end up with unhelpful invisible text in the links, like:

<a href="/sample-basic-page" rel="tag" title="" hreflang="und">Read more<span class="visually-hidden"> about </span></a>

Notice how it says "Read more about" but without the node's title. So, this is also an accessibility issue.

This is due to the way that the block is hiding the node's title (because it gets rendered as the block title - we don't want to see it twice).

I'll attach a patch to fix in a moment!

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Widgets

Created by

πŸ‡ΊπŸ‡ΈUnited States dsnopek USA

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

Comments & Activities

Production build 0.71.5 2024