Closed (fixed)
Project:
Taxonomy Term Reference Tree Widget
Version:
7.x-1.11
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
26 Nov 2018 at 09:33 UTC
Updated:
1 Dec 2020 at 23:13 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jenna1 commentedComment #3
hoporr commentedWe saw this error as well when switching to 7.2.
There is a minor bug in the code @ line 202
(NOTE that the original report is for line 718, we had line 202; so there may be two related or different issues)
if (isset($tree['children']) && is_array($tree['children']) && count($tree['children'] > 0)) {It has to be like this,
note in the original, that the closing parenthesis around 'count' is set wrong:
count($tree['children'] > 0)In the original, the inner term in count resolves to a boolean test, instead of testing the array.
Apprently this was not caught in php < 5.x, and only with the 7.x being more strict does the bug show.
Sorry about not having this as a patch, but I had to do the fix directly on a system without diff/patch capabilities.
Comment #4
jenna1 commentedI have now replaced line 202 with:
if (isset($tree['children']) && is_array($tree['children']) && count($tree['children'])> 0) {I run cron and cache, but the message comes again for line 718:
Warning: count(): Parameter must be an array or an object that implements Countable in _term_reference_tree_build_item() (Zeile 718 von...
line 718
if (($depth + 1 <= $element['#max_depth'] || !$element['#max_depth']) && property_exists($term, 'children') && count($term->children) > 0) {best regards, Jenna
Comment #5
fuerst commentedHi all, you got two errors covered here:
* Line 202: Missing parenthesis
* Lines 682/718: Accessing a non-Countable variable
The attached patch fixes both.
Comment #6
devenpro commentedThanks, this patch works fine.
Comment #7
fuerst commentedComment #9
alex_optimComment #10
alex_optimComment #12
msnassar commentedHere is a patch for 7.x-1.11
Comment #13
joegl commentedWe were getting this on 7.x-1.11 and the patch in #12 fixed it for us. It started showing up when we upgraded to 7.3. Should this be re-opened?