Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: aegersz on May 16, 2021, 11:16:42 AM

Title: fixing "count(): Parameter must be an array or an object that implements ..."
Post by: aegersz on May 16, 2021, 11:16:42 AM
I have tried and failed to fix this bug; this came in at php 7.2 and the full error is:

count(): Parameter must be an array or an object that implements Countable

the offending line of code is:
return count(isset($context['friends']) ? $context['friends'] : null);

any suggestions ?
Title: Re: fixing "count(): Parameter must be an array or an object that implements ..."
Post by: d3vcho on May 16, 2021, 11:25:41 AM
Can you attach the whole file?
Title: Re: fixing "count(): Parameter must be an array or an object that implements ..."
Post by: shawnb61 on May 16, 2021, 11:35:30 AM
Try replacing 'null' with 'array()'.
Title: Re: fixing "count(): Parameter must be an array or an object that implements ..."
Post by: aegersz on May 16, 2021, 11:39:29 AM
Here is the full code ...
Title: Re: fixing "count(): Parameter must be an array or an object that implements ..."
Post by: aegersz on May 16, 2021, 11:44:20 AM
Quote from: shawnb61 on May 16, 2021, 11:35:30 AM
Try replacing 'null' with 'array()'.

I think that worked ... many, many thanks if it stays that way !