Bug in components/com_content/helpers/route.php

Contact the Development Working Group here: http://groups.google.com/group/joomla-dev-general

This forum is now closed and archived.
Locked
pkwin
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Wed Oct 01, 2008 6:21 pm

Bug in components/com_content/helpers/route.php

Post by pkwin » Wed Oct 01, 2008 6:54 pm

I am in the process of setting up a new site (currently in localhost) using J1.5.7.
I have installed Virtuemart and a couple of modules (non-VM). I set up a few menu items (all VM related) and installed a module from yootheme (accordion) to display some articles in a module position. There is only one content section and within that only one category. That category has three articles and the yootheme/accordion module is configured to display all three articles. (this is a configuration that I have working satisfactorily in a development site using J1.5.3)
The module shows the articles but also shows a warning message as follows:
"Warning: Invalid argument supplied for foreach() in C:\www\EfaB_20080929\components\com_content\helpers\route.php on line 119"
On investigation, I found that I was able to resolve the issue by adding an additional is_array($items) test before line 117 is called and that appears to resolve the problem.
The problem appears to be caused by the absence of any menu items that are linked to com_content
in summary, changing components/com_content/helpers/route.php as follows resolved the problem:

Code: Select all

			foreach($items as $item)
			{
				if ((@$item->query['view'] == $needle) && (@$item->query['id'] == $id)) {
					$match = $item;
					break;
				}
			}
to

Code: Select all

			if(is_array($items))
			{
				foreach($items as $item)
				{
					if ((@$item->query['view'] == $needle) && (@$item->query['id'] == $id)) {
						$match = $item;
						break;
					}
				}
			}
I hope this is helpful and posted in the correct place.
Regards
Phil

Kentheteaman
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Mon Nov 24, 2008 7:03 pm

Re: Bug in components/com_content/helpers/route.php

Post by Kentheteaman » Mon Nov 24, 2008 7:11 pm

Hi Phil,

I have an identical error like yours.

Warning: Invalid argument supplied for foreach() in /home/hztdjozq/public_html/SSL/components/com_content/helpers/route.php on line 117

Warning: Invalid argument supplied for foreach() in /home/hztdjozq/public_html/SSL/components/com_content/helpers/route.php on line 117

Warning: Invalid argument supplied for foreach() in /home/hztdjozq/public_html/SSL/components/com_content/helpers/route.php on line 117


I am a newbe to php and Joomla.
Will you be kind enough to help me how to correct this error.
I will be really greatful.

regards,
ken :( :(

pkwin
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Wed Oct 01, 2008 6:21 pm

Re: Bug in components/com_content/helpers/route.php

Post by pkwin » Fri Nov 28, 2008 7:39 am

Ken,
You don't give anybody much chance to help you. When you report a problem please provide details of software versions that may be relevant and instructions for duplicating the problem.

That said, the problem that I had was caused by the code assuming that the variable being processed was an array, but it wasn't. All I did was add a test to check for the presence of an array first. Looks like you have a completely unrelated problem because it has occurred in a different program for one of many possible reasons.

To investigate this, look at the program concerned and try to work out what is wrong, perhaps by displaying values using 'echo'. I use the extension jdump which you can find in the extensions section of this site. That allows the values of variables to be displayed in a separate window.

Can't really help any more than that.

Regards
Phil

Kentheteaman
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Mon Nov 24, 2008 7:03 pm

Re: Bug in components/com_content/helpers/route.php

Post by Kentheteaman » Fri Nov 28, 2008 5:55 pm

Hi Phill,

Thank you for the reply.

Since posting my plea for help - I noticed your comment in your first post - "The problem appears to be caused by the absence of any menu items that are linked to com_content".

So I added a menu item linking the "Articles".
The error message disappeared !!!
And thats that.

May be I just got lucky.

regards,
ken

leoneiva
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Fri Oct 20, 2006 9:09 pm

Re: Bug in components/com_content/helpers/route.php

Post by leoneiva » Sun Dec 07, 2008 5:26 pm

Thanks,

It works,

mamies
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Tue Jan 06, 2009 4:08 am

Re: Bug in components/com_content/helpers/route.php

Post by mamies » Mon Jun 29, 2009 1:54 am

Hmm when i include my articles as menu items it works as well. Although our site is about 150 pages in size and these cannot all be linked to menus for obvious reasons. I was wondering if anyone knows the actual reason why this is happening


Locked

Return to “Development”