TypeError on 'Status' Page When No Content Types Enabled for Content Readability

Created on 8 September 2023, 10 months ago
Updated 13 September 2023, 10 months ago

Problem/Motivation

When there are no content types enabled for the "Content Readability" module, the "Status" page throws an error:

"The website encountered an unexpected error. Please try again later. TypeError: array_values(): Argument #1 ($array) must be of type array, null given in array_values() (line 19 of modules/contrib/content_readability/content_readability.install)."

Steps to reproduce

  1. Install and enable the Content Readability module.
  2. Navigate to the "Status" page without enabling any content types for Content Readability.

Proposed resolution

The issue is with the following line in the module:

$allowed_bundles = \Drupal::config('content_readability.settings')->get('content_readability_visibility');

It returns null when no bundles are enabled, which leads to an error when array_values() is called. The proposed resolution is to change the line to:

$allowed_bundles = \Drupal::config('content_readability.settings')->get('content_readability_visibility') ?? [];

Remaining tasks

  1. Update the relevant line of code in content_readability.install.
  2. Test the change to make sure the error is resolved.
  3. Submit a patch for review.
  4. Document the change.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia amjad1233 Brisbane

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

Comments & Activities

Production build 0.69.0 2024