undefined revision_log_message key error

Created on 15 July 2025, 19 days ago

Problem/Motivation

If you have revisions enabled for media, but do NOT have revision log messages enabled in the edit form, editing a media entity will result in two warnings:

  • Warning: Undefined array key "revision_log_message" in override_media_options_form_alter() (line 26 of sites/default/modules/contrib/override_media_options/override_media_options.module).
  • Warning: Trying to access array offset on null in override_media_options_form_alter() (line 26 of sites/default/modules/contrib/override_media_options/override_media_options.module).

In revision_log_message.module. line 26 is:
$form['revision']['#access'] = $form['revision_log_message']['#access'];
but the 'revision_log_message' key is not present if there is no revision log message field in the Default form view. Enabling the field populates the field and removes the message, but this should not be necessary. The module should work fine without requiring the revision log field.

This can easily be resolved with a null coalescing operator, but I'm not sure what the logic in this line of code is here for. Should it default to true of false?

  • $form['revision']['#access'] = ($form['revision_log_message']['#access']) ?? TRUE;
  • $form['revision']['#access'] = ($form['revision_log_message']['#access']) ?? FALSE;

I've played with settings for revisions and revision logs, and I can't get the log field to show up whatever settings I apply. And whether the null coalescing operator is true or false doesn't seem to matter for our site.

It is interesting that the following bit of code does test for whether the key is set. We need a similar bit of validation for the previous line.

Steps to reproduce

Enable this module and media revisions on a Drupal site, but without including the revision log field in the media editing form.

Proposed resolution

Add the appropriate null coalescing operator, as indicated above.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States daletrexel Minnesota, USA

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024