?
avatar Quibi
Quibi
17 May 2017

When there is any item to show in a (frontend) tag view, the php interpreter indicates the following error:

Notice: Trying to get property of non-object in .../components/com_tags/views/tag/view.html.php
on line 120

The error appears when $items is equal to false and, so, counting a false returns 1 —it's PHP implementation. That causes that executing $items[0] launches the error because $count > 0 and $items is not an object.

Steps to reproduce the issue

Not easy. I get this error because a tag, according to Joomla CMS, is not linked to any item —which is false!!!

So I suggest to mock $items and make it false to check this error.

Expected result

No error.

Actual result

Notice: Trying to get property of non-object in .../components/com_tags/views/tag/view.html.php 
on line 120

System information (as much as possible)

Joomla 3.7.0
PHP 7.0.13
MacOs 10.12.4

Additional comments

This error is minor (even trivial) since it does not affect the output of the view. But it still an error and can be caused additional errors in future versions of the view.

I would like to propose the next solution:

Change line 119 to: $count = ($items) ? count ($items) : 0;

Although it can be changed the line 120 (where $count is tested) and $count is not used later, I think is more logical to get a zero when a false is counted.

avatar Quibi Quibi - open - 17 May 2017
avatar joomla-cms-bot joomla-cms-bot - change - 17 May 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 17 May 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 17 May 2017
Category com_tags
avatar PhilETaylor
PhilETaylor - comment - 17 May 2017

Please close and test #16077

avatar franz-wohlkoenig franz-wohlkoenig - change - 17 May 2017
Status New Discussion
avatar zero-24 zero-24 - change - 17 May 2017
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2017-05-17 13:19:26
Closed_By zero-24
avatar zero-24 zero-24 - close - 17 May 2017
avatar zero-24
zero-24 - comment - 17 May 2017

Thanks @PhilETaylor

Add a Comment

Login with GitHub to post a comment