Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When removing a paragraph on PHP 7.2 I'm getting:
Warning: count(): Parameter must be an array or an object that implements Countable in paragraphs_field_widget_embed_validate() (line 712 of paragraphs/paragraphs.field_widget.inc).
Comment | File | Size | Author |
---|---|---|---|
#3 | paragraphs-count-php71-3010938-3.patch | 876 bytes | sickness29 |
Comments
Comment #2
bramvandenbulcke CreditAttribution: bramvandenbulcke commentedI also had this issue on a Drupal 7 install with PHP 7.2.
At the moment I'm able to bump my Drupal 7 installs to PHP 7.1. Some smaller issues on Paragraphs and Date are holding me back to move to PHP 7.2. I hope this patch will get in eventually.
Comment #3
sickness29 CreditAttribution: sickness29 at DevBranch commentedReworked patch a bit in the same way as done here #2992575: PHP 7.2 - Error occurring: Warning: count(): Parameter must be an array or an object that implements Countable in field_collection_field_widget_embed_validate().
Comment #4
jacob.embree CreditAttribution: jacob.embree at St. Louis Integration commentedTo me the first patch makes more sense than #3. The intention of the statement really is to check if the value is empty. The count itself is not important, so it isn't necessary to check if it is some sort of countable.Comment #5
jacob.embree CreditAttribution: jacob.embree at St. Louis Integration commentedNevermind about #4. I just read the comment in
_form_validate()
:#3 looks good, but I haven't manually tested it.
Comment #6
klausiManually tested, makes sense!
Comment #7
skylord CreditAttribution: skylord commented#3 works OK, thanks. Commit and new release are must have as php5 is deprecated now...
Comment #8
banoodle CreditAttribution: banoodle at Kanopi Studios commentedHi and thanks for the patch!
Can someone provide me with details on how to reproduce this warning? Above it says "When removing a paragraph" but I'm not clear what exactly that means.
I have tried removing a paragraph from a node, from a content type and from the site, but none of those things generated the waring.
We're not seeing this warning (and we have all warnings/errors and logging enabled) and I would ideally like to reproduce the warning prior to patching.
I know I may sound overly cautious, but this is for a very complex and highly customized site, so I really like to be sure I'm scrutinizing the right part of the module's functionality so as to not introduce new problems.
Comment #9
bramvandenbulcke CreditAttribution: bramvandenbulcke commented@banoodle: sure PHP 7.2 is running on your site? Check your status report to see the active PHP version.
Comment #10
Christian DeLoach CreditAttribution: Christian DeLoach commentedThis error message started appearing for me as soon as I added a link field (https://www.drupal.org/project/link) to my paragraph. When I remove the field the error goes away. Add the field back in and the error returns. The error only appears when the link field has a value. When the link fields are empty, the error does not appear.
Comment #11
donaldwbabcock CreditAttribution: donaldwbabcock commented#3 works on my 7.x-1.x-RC5 running on php7.2.
Just a comment, I've seen two implementations of "$is_empty_multiple" between D7Core and in various modules. Core currently uses count($elements['#value']) == 0; where as this patch uses (!count($elements['#value']));.
See https://api.drupal.org/api/drupal/includes%21form.inc/function/_form_val...
The result is the correct true or false in both cases, but we have a note in this function that this code came from _form_validate, so some consistency may be in order.
Either way, RTBC, as we need some of these php7.x related little changes committed and either RC6 rolled, or a final 7.x-1.0 rolled.
Comment #12
jenlampton+1 for RTBC
Comment #13
interdruper CreditAttribution: interdruper commentedSame case use as #10. Patch #3 removes de warning on PHP 7.2. IMHO, RTBC.
Comment #14
bradallenfisher CreditAttribution: bradallenfisher commentedI was having this error when any nested paragraph fields were set to required.
just applied the patch in #3 manually, and it stops the warning. Drupal 7.67 - PHP 7.2 on Acquia cloud enterprise.
Thanks. didn't try first patch. so it may work also.
Comment #15
miro_dietikerI committed this change to clean-up the queue. Thx all for pushing. :-)