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.
views_many_to_one_helper::add_filter() performs count()
on a variable that may not be an array. In PHP 7.2 this generates a warning with the following text:
Warning: count(): Parameter must be an array or an object that implements Countable in views_many_to_one_helper->add_filter() (Line 1090 in views/includes/handlers.inc).
Comment | File | Size | Author |
---|---|---|---|
#32 | views-n2977851-32.patch | 2.01 KB | brandonpost |
#27 | views-n2977851-27.patch | 4.16 KB | DamienMcKenna |
#24 | views-n2977851-23.patch | 1.88 KB | DamienMcKenna |
#21 | views-php72_count-2977851-21.patch | 1.96 KB | VladimirAus |
#18 | 2977851-views-php72-count-18.patch | 1.96 KB | VladimirAus |
Comments
Comment #2
Jorrit CreditAttribution: Jorrit at nCode for DOM Digital Online Media GmbH commentedPlease see the attached patch.
Comment #3
DamienMcKennaThanks!
Comment #4
dsnopekRTBC+1! Used in Panopoly
Comment #6
DamienMcKennaCommitted. Thanks!
Comment #8
cboyden CreditAttribution: cboyden at UC Berkeley Web Platform Services commentedThe patch in #2 does not apply to Views 7.x-3.21, here's a re-roll.
Comment #9
darrell_ulm CreditAttribution: darrell_ulm as a volunteer commentedThe patch in #2 does not apply to Views 7.x-3.23, here's an additional re-roll.
Comment #10
darrell_ulm CreditAttribution: darrell_ulm as a volunteer commentedAnd here is the file mentioned in #9
Comment #11
xlin CreditAttribution: xlin as a volunteer commented@DamienMcKenna this commit was reverted by https://git.drupalcode.org/project/views/commit/fbafd79a763f19d8c06039f3...?
Comment #12
Alina Basarabeanu CreditAttribution: Alina Basarabeanu commentedThis issue was fixed previously with the patch from #2 but we lost it with this commit https://git.drupalcode.org/project/views/commit/fbafd79a763f19d8c06039f3...
@DamienMcKenna please change this ticket back to needs review
Comment #13
demonde CreditAttribution: demonde commentedI have a similar issue
The code in views_handler_argument_term_node_tid_depth.inc should be probably changed in a similar way from
if (count($tids->value) > 1) {
to
if (is_array($tids->value) && count($tids->value) > 1) {
Comment #14
mariiadeny CreditAttribution: mariiadeny as a volunteer and commentedComment #15
michfuer CreditAttribution: michfuer at Mediacurrent commentedAgreed with #11 and #12, the patch in #2 appears to have been unintentionally reverted when the 7.x-3.21 security updates were merged into the 7.x-3.x branch.
A maintainer should re-open and probably set to 'Needs review' for the patch in #14.
Comment #16
DamienMcKennaWhoops.
PSA: this is why we need moar test coverage (-:
Comment #17
rclemings CreditAttribution: rclemings as a volunteer commentedEnd of security support for PHP 7.1 is about five weeks ago. Any way this patch could be in a release before then?
Comment #18
VladimirAusUpdating patch with a bit of optimisation.
Comment #20
DamienMcKennaThis line doesn't need the extra brackets around the is_array() statement:
Comment #21
VladimirAusCheers @DamienMcKenna.
Updated patch.
Comment #23
DamienMcKennaRerolled.
Let's fix this for the next release.
Comment #24
DamienMcKennaComment #25
DamienMcKennaComment #27
DamienMcKennaHow about this? I'm reverting part of the change in the hopes of limiting what causes problems, we can deal with other count() problems in another issue.
Comment #28
DamienMcKennaOk, this more limited change passes for both 7.4 and 8.0, so that's sufficient for now.
Comment #30
brandonpost CreditAttribution: brandonpost as a volunteer and commentedHi Damien, the patch for this issue released in 7.x-3.26 appears to be causing some problems (please see Views 7.x-3.26 breaks glossary view of taxonomy terms causing "SQLSTATE[42000]: Syntax error or access violation: 1064).
I see how patch #27 attempts to simplify the logic, but it doesn't take into account the case if $value is a nested array. The original logic did that, but the problem with the original logic is that it didn't test is_array($value) before calling count($value).
Here is a patch that reverts back to the original logic, but adds is_array($value), which solves the original issue of 'count() on non-Countable'. The patch also implements demonde's suggestion in #13 to make the same correction in views_handler_argument_term_node_tid_depth.inc.
Comment #31
brandonpost CreditAttribution: brandonpost as a volunteer and commentedJust saw another potential issue with the original logic. Here's an updated patch.
Comment #32
brandonpost CreditAttribution: brandonpost as a volunteer and commentedOne more patch also incorporating a correction to views_handler_argument_term_node_tid_depth_join.inc that VladimirAus had made in #21.
Comment #33
ethomas08 CreditAttribution: ethomas08 commentedPatch #32 does not work for me for the 7.x-3.26 release for the glossary bug my team is experiencing (more info in duplicate issue: https://www.drupal.org/project/views/issues/3305385)
Uploading a patch that fixes this error, from one of Damien's commits.
Comment #35
DamienMcKenna@ethomas08: Please clarify what happens when you tried #32, in what way did it not work?
Comment #36
DamienMcKennaCommitted. Again. Thank you.