Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291529

implode(): Argument #1 ($pieces) must be of type array, string given in implode()

$
0
0

Problem/Motivation

After migration from PHP 7.4 to PHP 8.0, and trying to write a Comment, we get this error:
TypeError: implode(): Argument #1 ($pieces) must be of type array, string given in implode() (line 1104 of /DRUPAL_FOLDER/modules/field/field.module).

Steps to reproduce

Just try to create a comment.

Proposed resolution

Change from this:
$variables['classes'] = implode('', $variables['classes_array']);
to this:
if(is_array($variables['classes_array']))
{
$variables['classes'] = implode('', $variables['classes_array']);
}
else if (is_string($variables['classes_array']))
{
$variables['classes'] = implode('', (array)$variables['classes_array']);
}
Maybe there is a better way to do this.


Viewing all articles
Browse latest Browse all 291529

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>