avatar toivo
26 Nov 2018

Steps to reproduce the issue

Install Weblinks 3.6.0 Package from https://extensions.joomla.org/extensions/extension/official-extensions/weblinks/ on Joomla 3.9.0 using PHP 7.2 and set to report PHP warnings.

Go to Components - Web Links and add any URL as New Web Link to the existing default category Uncategorised with default options, Save & Close.

Create a new menu item and select Web Links - List All Web Link Categories with default options, Save & Close.

Go to the front end and select the new link from the menu.

Expected result

The list shows the default category Uncategorised.

Actual result

The list shows the category Uncategorised after the PHP warning:
Warning: count(): Parameter must be an array or an object that implements Countable in C:\www\joomla380\components\com_weblinks\models\categories.php on line 95

System information (as much as possible)

Joomla 3.9.0 and also Joomla 3.9.0 updated with Joomla_3.9.1-dev-Development-Update_Package.zip
PHP 7.2.11

Additional comments

Fixed by inserting the following lines before line 95 in components/com_weblinks/models/categories.php

if (!is_array($this->_items)) { $this->_items = array(); }

Ref. topic "Weblinks Categories page - Warning: count() at https://forum.joomla.org/viewtopic.php?f=715&t=967481

avatar toivo toivo - open - 26 Nov 2018
avatar chmst
chmst - comment - 19 Apr 2019

The issue is caused by a defective query.

Change the lines 153 - 154 by

$query->select('CASE WHEN a.created_by_alias != "" THEN a.created_by_alias ELSE ua.name END AS author')
->select('ua.email', 'author_email')

And the $item is not empty.

avatar HLeithner
HLeithner - comment - 25 Apr 2019

@chmst can you create a PR to fix this?

avatar chmst
chmst - comment - 25 Apr 2019

Yes - but it was my fault - I have mixed up different issues.

Add a Comment

Login with GitHub to post a comment