Undefined array keys for comments if custom preprocessing is skipped

Created on 19 November 2022, about 2 years ago
Updated 16 February 2023, almost 2 years ago

Problem/Motivation

The comment entity has lots of preprocessing to create extra variables in template_preprocess_comment(). There is an option to remove this, introduced in #3090187: Mechanism to disable preprocessing of base fields in comment entity type so they can be configured via the field UI . You can enable the option with a hook, or more easily by enabling the module manage_display.

This module relies on the extra preprocessing, without making any checks that it is present.

Notice: Undefined index: author in rdf_preprocess_comment() (line 489 of core/modules/rdf/rdf.module).

Steps to reproduce

  1. Download Manage Display version 2.0.0-beta1 using composer.
  2. Install the module.
  3. Navigate to Manage » Structure » Comment types » Manage display (Default comments)
  4. Move the "Subject" field to the "Disabled" part of the form.
  5. Save.
  6. Enable this module for comments.
  7. Open up an existing Article that has comments enabled.
  8. See the Notice appear.

Proposed resolution

rdf_preprocess_comment() should check if variables are present before using them. The code in template_preprocess_comment() is a good guide to see what variables might be present or absent.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇳🇴Norway gisle Norway

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