Undefined array key moderation_state in commerce promotion view form alter

Created on 3 October 2024, 3 months ago

When adding a moderation_state field to a view (any view) causes ajax loading issue and produces this error:

Warning: Undefined array key "moderation_state" in commerce_promotion_form_views_ui_config_item_form_alter() (line 106 of /var/www/html/web/modules/contrib/commerce/modules/promotion/commerce_promotion.module).

Once I dug into see what the issue was I found a related/similar issues reported for commerce in another area; commerce price https://www.drupal.org/project/commerce/issues/3113031

- Which for the most part is identical to this error, just for a different commerce sub module promotion. Based on the patch for issue 3113031 I've attached a patch for this.

Modifying: (line 106)
if ($handler instanceof EntityField && !empty($handler->definition['entity_type'])) {
to:
if ($handler instanceof EntityField && !empty($handler->definition['entity_type']) && !empty($handler->options['entity_field'])) {

Didn't investigate any further than that - there may be other sub modules using $handler instanceof EntityField in a views form alter that should also get updated to prevent issues with moderation_state.

🐛 Bug report
Status

Active

Version

2.40

Component

Promotions

Created by

🇺🇸United States sidgrafix

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

Comments & Activities

Production build 0.71.5 2024