Buy Now
Sign in

invalid database call done by plugin : SOLVED

rgoncalves , June 02 2010
r
rgoncalves

Hi,
Just recently I noticed a problem in the chronocomments plugin in some pages. Everythign was working fine, but as I’ve been developing an heavy duty extension to a particular client I left the debug on in joomla’s configuration.php. Actually I’ve left it intentionally as it helps me clean up some of my code.

Anyway, when opening a ‘Section Blog Layout’ menu item I came across the following error:

				500 - JDatabaseMySQL::query: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 SQL=SELECT a.*, CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug, CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug FROM jos_content AS a LEFT JOIN jos_content_frontpage AS f ON f.content_id = a.id INNER JOIN jos_categories AS cc ON cc.id = a.catid INNER JOIN jos_sections AS s ON s.id = a.sectionid WHERE a.id= 


I think I found the solution. The problem seems to be in the
				plgContentChronocomments( &$row, &$params, $page=0 )
				

which always assumes $row is always a content item, which is not the case in a ‘Section Blog Layout’ page.
I added the following line of code right on top of it and everything is now working just fine:
				function plgContentChronocomments( &$row, &$params, $page=0 )
{
if (!$row->id) return true;


Don’t forget that this error still occurs every time when you open pages like ‘Section Blog Layout’ and similar, but you simply do not get the error because the debug is turned off.
Still the code is making unnecessary calls to the database and generating unnecessary error log entries. Therefore I would like to suggest this to be added to the long waiting new version :D