Support from Acquia helps fund testing for Drupal Acquia logo

Comments

xpersonas created an issue. See original summary.

  • xpersonas authored cdd7b52 on 8.x-1.x
    Issue #2989199 by xpersonas: Fixing Array to String Notice for PHP 7.x
    
sergei_semipiadniy’s picture

Version: 8.x-1.0-alpha6 » 8.x-1.x-dev
Status: Active » Needs review
FileSize
778 bytes
7.74 KB

Hi,

@xpersonas, I installed fresh drupal 8.5.6 and faced with a warning, probably, that has been appeared after this fix.

File with dump of a warning is enclosed, as well as a fresh patch.

Regards

jwjoshuawalker’s picture

Same error here. The patch fixes it, but I feel like we could do this more cleanly.

reszli’s picture

slightly modified patch to remove all errors
I agree that this is probably not the best way, but who's in a hurry...

mariagwyn’s picture

I can confirm that the patch silences the error.

xpersonas’s picture

I'm debating if this should be a new issue, but it involves the exact same piece of code so i'm putting it here. I'm getting a notice about the implode function in this check....

Warning: implode(): Argument must be an array

I have a new patch that breaks the argument into two lines, checking that it's an array first. If you guys have a better way to handle, let me know. But this is working for me at the moment.

mvonfrie’s picture

I have the exact same issue with Drupal 8.6.10 now and figured out that $variables['attributes']['placeholder'] can be a string instead of an array, either empty or with a placeholder value (e. g. for a Drupal Commerce price field the default placeholder is 9,99 and "9.99" == $variables['attributes']['placeholder'].

According to https://secure.php.net/manual/en/function.implode.php the implode function has two signatures:

implode(string = "", array)
implode(array)

If $variables['attributes']['placeholder'] is expected to be an array as in all previous patches but actually is a string, none of the implode function matches because the string is optional and the array is required.

mvonfrie’s picture

Here is a new patch with different checks whether $variables['attributes']['placeholder'] is a string or an array.

bleen’s picture

Status: Needs review » Reviewed & tested by the community

Just tested with alpha7 and this worked perfect ... based on the comments in #8 this fix makes sense.

tanc’s picture

Another confirmation that the patch fixes the issue.

thejimbirch’s picture

That patch in #9 applies to alpha7 and fixes the warnings.

To Verify:
Visit /admin/reports/updates
Visit /admin/reports/dblog and verify the PHP Warning did not post.

e0ipso’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the patch everyone! This should be merged now.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

ocastle’s picture

Version: 8.x-1.x-dev » 2.x-dev
FileSize
959 bytes

This change has been lost in 2.x

Attaching Patch.

thejimbirch’s picture

You may want to open a new issue @ocastle. Only maintainers can reopen closed issues so they may not see this.

ocastle’s picture