MyBB Community Forums
[Rejected] php 7.2 count(): Parameter must be an array or an object that implements Countable - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Development (https://community.mybb.com/forum-161.html)
+--- Forum: MyBB 1.8 Development (https://community.mybb.com/forum-165.html)
+---- Forum: 1.8 Bugs and Issues (https://community.mybb.com/forum-157.html)
+----- Forum: Rejected (https://community.mybb.com/forum-184.html)
+----- Thread: [Rejected] php 7.2 count(): Parameter must be an array or an object that implements Countable (/thread-224587.html)



php 7.2 count(): Parameter must be an array or an object that implements Countable - panayot - 09-11-2019

Edit2: Sorry, this is not related to MyBB. I have confirmed that errors apear only when viewing a user profile through the Tapatalk plugin. This plugin calls some fucntions from inc/functinos_online.php and maybe uses incorrect parameters.

Hi, I noticed these warnings:

<error>
<dateline>1568219801</dateline>
<script>inc/functions_online.php</script>
<line>606</line>
<type>2</type>
<friendly_type>Warning</friendly_type>
<message>count(): Parameter must be an array or an object that implements Countable</message>
</error>

<error>
<dateline>1568219801</dateline>
<script>inc/functions_online.php</script>
<line>624</line>
<type>2</type>
<friendly_type>Warning</friendly_type>
<message>count(): Parameter must be an array or an object that implements Countable</message>
</error>

<error>
<dateline>1568219801</dateline>
<script>inc/functions_online.php</script>
<line>636</line>
<type>2</type>
<friendly_type>Warning</friendly_type>
<message>count(): Parameter must be an array or an object that implements Countable</message>
</error>

<error>
<dateline>1568219801</dateline>
<script>inc/functions_online.php</script>
<line>648</line>
<type>2</type>
<friendly_type>Warning</friendly_type>
<message>count(): Parameter must be an array or an object that implements Countable</message>
</error>

<error>
<dateline>1568219801</dateline>
<script>inc/functions_online.php</script>
<line>660</line>
<type>2</type>
<friendly_type>Warning</friendly_type>
<message>count(): Parameter must be an array or an object that implements Countable</message>
</error>

<error>
<dateline>1568219801</dateline>
<script>inc/functions_online.php</script>
<line>702</line>
<type>2</type>
<friendly_type>Warning</friendly_type>
<message>count(): Parameter must be an array or an object that implements Countable</message>
</error>

<error>
<dateline>1568219801</dateline>
<script>inc/functions_online.php</script>
<line>717</line>
<type>2</type>
<friendly_type>Warning</friendly_type>
<message>count(): Parameter must be an array or an object that implements Countable</message>
</error>


RE: php 7.2 count(): Parameter must be an array or an object that implements Countable - noyle - 09-11-2019

(09-11-2019, 04:45 PM)panayot Wrote: Edit2: Sorry, this is not related to MyBB. I have confirmed that errors apear only when viewing a user profile through the Tapatalk plugin. This plugin calls some fucntions from inc/functinos_online.php and maybe uses incorrect parameters.

Hi, I noticed these warnings:

<error>
<dateline>1568219801</dateline>
<script>inc/functions_online.php</script>
<line>606</line>
<type>2</type>
<friendly_type>Warning</friendly_type>
<message>count(): Parameter must be an array or an object that implements Countable</message>
</error>

(...)

Still can't get to understand why. In file ./inc/functinos_online.php there's a declaration of these variables before any function defined in this file can be called:
$uid_list = $aid_list = $pid_list = $tid_list = $fid_list = $ann_list = $eid_list = array();



RE: php 7.2 count(): Parameter must be an array or an object that implements Countable - panayot - 09-11-2019

I guess this line initializes the variables as empty arrays and should prevent exactly this error. But when this file is included by the plugin an error is generated here:

if(!is_array($attachments) && count($aid_list) > 0)


which means that $aid_list is somehow not initialized at that moment. Maybe the plugin somehow resets the initialized arrays. But the only mention of aid_list in the plugin code is this:

global $uid_list, $aid_list, $pid_list, $tid_list, $fid_list, $ann_list, $eid_list, $plugins, $user, $parameters;


But my PHP knowledge is not very good. I have sent bug report to Tapatalk.