Problem with paragraphs - can't access field settings any longer

Created on 3 September 2024, 3 months ago

Problem/Motivation

Field completeness is running for 2 years on a drupal 9 website. Now we decided two use paragraphs module and ept_accordion with the content type simple page. After creating two paragraph types it is not possible to complete the settings procedure. When clicking on field settings for any paragraph type, drupal throws an WSoD with the following error message:

TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array() (Zeile 346 in /var/www/html/web/modules/contrib/field_completeness/src/FieldCompletenessManager.php)

#0 /var/www/html/web/modules/contrib/field_completeness/src/FieldCompletenessManager.php(346): in_array('text', NULL)
#1 /var/www/html/web/modules/contrib/field_completeness/field_completeness.module(29):

Steps to reproduce

Install and enable field_completeness, paragraps and ept_accordion
Try to edit the field settings of a paragraph type, gives the above mentioned error.

Proposed resolution

It is quite easy to fix. Just check wether the array is empty. In the file field_completeness/src/FieldCompletenessManager.php change line 346 to 352 from

public function isAllowedParagraphType($type) {
     return in_array($type, $this->getAllowedParagraphTypes());
   }

to

public function isAllowedParagraphType($type) {
    $allowed_types = $this->getAllowedParagraphTypes();
    if (!is_array($allowed_types)) {
      return FALSE;
    }
    return in_array($type, $allowed_types);
  }
🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇩🇪Germany saccard

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

Comments & Activities

Production build 0.71.5 2024