Recent Topics

1 Apr 19, 2018 13:30    

b2evo v6.9.5 php 7.2.4 see
I have a warning that occurs in widgets/plugins that use the status of s post to decide if to show or not and only happens when logged in.

The warning is:

Warning: count(): Parameter must be an array or an object that implements Countable in H:\xampp\htdocs\\inc\items\model_item.funcs.php on line 903
( ( post_status IN ( 'published','community','protected','review','private' ) ) )

The text after 903 is that shown when I remove the comments from the echo in the relevant file at line 910

	elseif( count( $show_statuses ) )
	{ // we are not filtering so all status are allowed, add allowed statuses condition
		$where[] = $dbprefix.'status IN ( \''.implode( '\',\'', $show_statuses ).'\' )';

	$where = count( $where ) > 0 ? ' ( '.implode( ' OR ', $where ).' ) ' : '';

	echo $where;
	return $where;

There is a reference to the issue at and more to the point

Is there a resolution to this or is the option only to hide the warnings at this time?

Not to say I'm not looking to understand and find the solution

2 Apr 19, 2018 13:46

Solution ??

Looking at

I noticed that the functioncount() requires an array i.e. count([some data]) not count(some data) so I enclosed the data $show_statuses in square brackets and the warning has gone

	elseif( count( [$show_statuses] ) )
	{ // we are not filtering so all status are allowed, add allowed statuses condition
		$where[] = $dbprefix.'status IN ( \''.implode( '\',\'', [$show_statuses] ).'\' )';

I hope this is a reasonable solution, could some one confirm?

Just checked v6.9.7 and it is the same so have modified the file before upgrading
Just checked v6.10 beta and it is the same.

Modification working on my b2evo 6.9.5 with php5.4.41

3 Apr 19, 2018 17:34

Another call to count()

In file [/inc/items/model/_items.funcs.php]
Line 908 in v6.9.5
Line 915 in v6.10 beta

Modified with addition of square brackets to::
$where = count([$where]) > 0

4 Apr 19, 2018 17:52

One more call to count()

In file [/inc/items/model/_items.funcs.php]
Line 990 in v6.10
Line 983 in v6.9.5

I wonder if SELECT count(*) is proper?
Added square brackets and excerpts are showing ok in
v6.9.5 / php5.4.41
v6.9.5 / php7.2.4

$all_excerpt = $DB->get_var( 'SELECT count([*]) FROM evonet_items__item WHERE post_excerpt IS NULL AND '.$where_condition );
		$recreated_excerpts = 0;

5 Apr 20, 2018 00:44

You are mixing up the PHP count function with the SQL count function. Same name but different functions.

6 Apr 20, 2018 00:52

Hi Francois
Do you mean in post #4 SELECT count([*]) but that the php function ones are do need the square brackets?
I've removed the brackets from the SQL function

7 Apr 20, 2018 10:09

I've just noticed an alternative warning, which may have been there before as I hadn't check single posts and scrolled down. This warning is below the post and before the feedback, whether I'm logged in or not. So much for my 'fix' :)

Notice: Array to string conversion in H:\xampp\htdocs\\inc\items\model_item.funcs.php on line 905

Form is loading...

Open-source blog – This forum is powered by b2evolution CMS, a complete engine for your website.