localgovdrupal / localgov_workflows

Default editorial workflow for LocalGov Drupal content.
GNU General Public License v2.0
0 stars 1 forks source link

Unable to use Views Bulk Edit with Moderated Content #46

Closed rgcarr closed 1 year ago

rgcarr commented 1 year ago

If using the https://www.drupal.org/project/views_bulk_edit to build Views to edit content in bulk, there's a PHP error when attempting to use the Views-generated UI to edit content that has Content Moderation/Review associated with it:

TypeError: Drupal\localgov_review_date\Entity\ReviewDate::getActiveReviewDate(): Argument #2 ($langcode) must be of type string, null given

This is in https://github.com/localgovdrupal/localgov_workflows/blob/f3082b37ad8e8812a28df321b4f5e12467a0828e/modules/localgov_review_date/src/Plugin/Field/FieldWidget/ReviewDateWidget.php#L66

Solution

Add a fallback 'und' value to the language code: $langcode = $form_state->get('langcode') ?? 'und';

rgcarr commented 1 year ago

Created PR at https://github.com/localgovdrupal/localgov_workflows/pull/47