PHP 8.1.13 disallowed_paths none error

Created on 4 January 2023, almost 2 years ago
Updated 12 July 2023, over 1 year ago

Problem/Motivation

TypeError: implode(): Argument #1 ($pieces) must be of type array, string given in implode() (line 88 of /var/www/html/web/modules/contrib/file_mdm/src/Element/FileMetadataCaching.php)

Steps to reproduce

Proposed resolution

Check implode("\n", $element['#default_value']['disallowed_paths']) along with !empty

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs work

Version

2.5

Component

Code

Created by

🇮🇳India arijits.drush India

Live updates comments and jobs are added and updated live.
  • PHP 8.1

    The issue particularly affects sites running on PHP version 8.1.0 or later.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 7.3 & SQLite 3.28
    last update over 1 year ago
    10 pass
  • @uri_frazier opened merge request.
  • 🇺🇸United States uri_frazier Portland, Oregon

    I also was getting the same error originally reported along with the following:
    Warning: Trying to access array offset on value of type null in /app/web/modules/contrib/file_mdm/src/Element/FileMetadataCaching.php on line 66 Warning: Trying to access array offset on value of type null in /app/web/modules/contrib/file_mdm/src/Element/FileMetadataCaching.php on line 75

    The problem occurs (SettingsForm.php) when there is no default/value set in $this->config('file_mdm.settings').

    Also in the code below, splitting off the save() function doesn't work as intended.

    $this->config('file_mdm.settings')->set('metadata_cache', $form_state->getValue(['metadata_cache', 'settings']));
        // Only save settings if they have changed to prevent unnecessary cache
        // invalidations.
        if ($this->config('file_mdm.settings')->getOriginal() != $this->config('file_mdm.settings')->get()) {
          $this->config('file_mdm.settings')->save();
        }
    

    I've created a proposed solution here:
    https://git.drupalcode.org/project/file_mdm/-/merge_requests/23

    To reproduce this error, try configuring Metadata caching settings while running PHP 8.1.x and on a site that has not no previous Metadata caching settings saved in Drupal config.

Production build 0.71.5 2024