Undefined array key "id" in content_moderation_action_info_alter

Created on 7 April 2025, 18 days ago

Problem/Motivation

After updating Views Bulk Operations to the 4.3.4 there are warning on core content_moderation module complaining about undefined array key "id".

Views Bulk Operations is now filtering out the actions the user doesn't have permission to use. The problem comes when

function administerusersbyrole_action_info_alter(array &$definitions) {
  $definitions['user_add_role_action']['class'] = AddRoleUser::class;
  $definitions['user_remove_role_action']['class'] = RemoveRoleUser::class;
}

goes to replace the classes, it doesn't check if the action exists first.

Steps to reproduce

Install Views Bulk Operations to 4.3.2 or heigher and Administer Users by Role to 3.5.0, go to an admin view with VBO in it with a user with limited permissions. Warnings will be displayed.

Proposed resolution

To check if the action definition is set before modifying it.

function administerusersbyrole_action_info_alter(array &$definitions) {
  if (isset($definitions['user_add_role_action'])) {
    $definitions['user_add_role_action']['class'] = AddRoleUser::class;
  }
  if (isset($definitions['user_remove_role_action'])) {
    $definitions['user_remove_role_action']['class'] = RemoveRoleUser::class;
  }
}
🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

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