If I use the module with PHP 7.2 I get this warning:
Warning: count(): Parameter must be an array or an object that implements Countable a FacetapiDependencyFacet->getDefaultSettings() (línia 139 de /var/local/html/dadesobertes/sites/all/modules/contrib/facetapi_bonus/plugins/facetapi/dependency_facet.inc).
Affected line:
if (!count($this->defaultSettings)) {
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | non-countable-2938545-5.patch | 1.9 KB | bkosborne |
Comments
Comment #2
oriol_e9gWe need to avoid count() of non-countable objects like nulls: https://wiki.php.net/rfc/counting_non_countables
Comment #3
oriol_e9gComment #4
donquixote commentedThe patch works, but I would say it is a band-aid fix.
The real problem is that FacetapiDependencyFacet->$defaultSettings is not initialized in the constructor or in its declaration, so it will have the value NULL.
This also means that if ->settingsForm() is called before ->getDefaultSettings(), the initialization in ->getDefaultSettings() will not happen.
This is asking for trouble.
It would be great if the maintainer could illuminate us on the intention behind this.
Comment #5
bkosborneThere's no need for the is_array check. Instead an empty can be used instead which works with lots of different types.
Comment #6
vinmassaro commented@bkosborne: thanks for the patch, works.
Comment #7
bisonbleu commentedRan into this issue. Patch works for me too.
Comment #8
botrisMoving to major, PHP 7.1 is "security fixes only", making PHP 7.2 (or higher) the natural choice for current config.
Comment #9
joelpittetRTBC++
Comment #10
donquixote commentedMy concern from #4 still applies, I think.
Comment #11
joelpittet@donquixote you're right, maybe you could provide a patch with the place it should be initialized? It looks like it should be initalized already here:
Though it is a band-aid fix, I think it's an acceptable one considering all the changes are
!count()toempty()which will produce the same value check for NULL/[]/0 as it did before 7.2I'm still +1 on the current patch but happy to have help from @donquixote to improve on this.
Comment #12
firewaller commented+1
Comment #13
darren ohComment #14
oldspot commentedPatch from #5 works well for me too.
Comment #15
drupal_lib commented#5 worked for me - thanks!
Comment #16
joseph.olstadRTBC +1
Comment #17
gdaw commentedI am seeing this working fine in our dev environment
RTBC+1
Comment #18
travis-bradbury commentedThe concern from #4 is not wrong, but I'll give a "+1" to RTBC anyway because I think the patch preserves the original intent, which is all the issue should be obligated to do. It's bad design to have allowed the default settings to be null, but solving that doesn't have to be in the scope of this issue.
Comment #19
joseph.olstad***EDIT***
see next comment
***END EDIT***
Comment #20
joseph.olstadactually, fixed now see commit.