errors and broken cron if $dom_node in TocBuilder is null

Created on 16 July 2021, almost 3 years ago
Updated 22 January 2023, over 1 year ago

Problem/Motivation

Code errors at line 80 of src/TocBuilder.php if $dom_node is null.is

Steps to reproduce

First seen when clicking on 'Place block' buttons on block layout form and getting no response.

Create a node where a Table of Contents is after the first heading tag. (We place a summary of the node before the TOC.) Use TOC Filter module. The first heading tag is a DOMNode with an id added by TOC Filter, but it has no parent.

Proposed resolution

Change
$dom_node->parentNode->replaceChild($fragment_node, $dom_node);
to

if($dom_node->parentNode) {
  $dom_node->parentNode->replaceChild($fragment_node, $dom_node);
} 

NB checking $dom_node is not null does not fix the issue, which is with a valid $dom_node with no parent. PHP 7.4.3

Remaining tasks

Make patch or PR or just update dev version.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom John_B London (UK), Worthing (UK), Innsbruck (Tirol)

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

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.69.0 2024