Keyword

Category RSS Feed 404 Error - PHP Error

More
4 years 4 months ago - 4 years 4 months ago #174005 by SD
I have a site that I am working on to replace the current production site. I have moved all my data and when I attempt to load the RSS feeds for the categories in K2 it returns a 404 error.

My host looked into the error and found that when the RSS feed is loaded it returns the following error in php.

[11-Dec-2019 18:43:35 UTC] PHP Warning: count(): Parameter must be an array or an object that implements Countable in .../templates/ts_newslinen/html/com_k2/templates/default/item.php on line 314

[11-Dec-2019 18:45:15 UTC] PHP Warning: count(): Parameter must be an array or an object that implements Countable in .../templates/ts_newslinen/html/com_k2/templates/default/item.php on line 314

That line in the item.php is as follows.

"<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>"

I have error reporting set at maximum but not seeing any errors returned. You can see the page that is returning the error on the RSS feed by going to bit.ly/2qO1Bk4

On the production site in which I cloned the development site from RSS feeds work without issue. The only difference between the two sites is an updated template that I installed that will allow me to move to a newer version of php.

Current info on the site:

Joomla - 3.9.13
K2 - 2.10.1
PHP - 7.2

Thanks for the help.
Last edit: 4 years 4 months ago by SD.

Please Log in or Create an account to join the conversation.

More
4 years 4 months ago #174029 by JoomlaWorks
Replied by JoomlaWorks on topic Category RSS Feed 404 Error - PHP Error
The category feeds are indeed broken up to v2.10.2. So you need to grab v2.10.3 (dev) from github.com/getk2/k2/archive/master.zip in which I fixed that issue today. It's 100% safe to upgrade to it.

As for the warnings you get, these come from your template overrides for K2 and they need to be slightly updated to work with PHP 7.2+.

In the example you mention, change:
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>

to:
<?php if($this->item->params->get('itemExtraFields') && !empty($this->item->extra_fields) && count($this->item->extra_fields)): ?>

This should do the trick. Make sure you update all "count(...)" references in your K2 template overrides like so.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
4 years 4 months ago - 4 years 4 months ago #174041 by SD
Updating K2 to v2.10.3 dev release fixed the issue.

Thanks for the help.
Last edit: 4 years 4 months ago by SD. Reason: Corrected version number

Please Log in or Create an account to join the conversation.

More
4 years 4 months ago #174044 by JoomlaWorks
Replied by JoomlaWorks on topic Category RSS Feed 404 Error - PHP Error
You mean v2.10.3 (dev)... :)

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
4 years 4 months ago #174045 by SD
Ha. Yes correct on that. I will make the edit to the post for the next person who might find this.

Please Log in or Create an account to join the conversation.

More
4 years 4 months ago #174046 by JoomlaWorks
Replied by JoomlaWorks on topic Category RSS Feed 404 Error - PHP Error
Cool :)

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum