Page 1 of 1

Proposal of improvements in mod_phocagallery_random_image?

Posted: 26 Jan 2009, 14:53
by zocha
Hi,

I thing I've found a typo in line 347 of mod_phocagallery_random_image.php it looks like follows:

Code: Select all

$image = '';
Shouldn't it be:

Code: Select all

$images = '';
as there is no $image use in following lines, only $images value check?

Before the following line (building of the query) there is no check if $implodeAllowedCategoriesArray isn't an empty string (rare but possible), which in my case leads to "500 - JDatabaseMySQL::query: 1064 - You have an error in your SQL syntax; ...".

I've found also an interesting post concerning the speed of ORDER BY RAND() in big tables which could be important with some biiiig galeries and I think it may help sometimes with the query described above. The first example is broken (not proper html), so you must look at the source of the page.

EDIT:
I've tested it and it's good for LIMIT 1, not for more, and the lover ID's have bigger chance to be caught when some record was deleted or unpublished. :( Interesting proposition anyway.

And one thing more. I've changed last lines of the file from:

Code: Select all

} else {
	$i = 0;
	$output[$i] = ''; // there is no image to get it as random image
}

require(JModuleHelper::getLayoutPath('mod_phocagallery_random_image'));
?>
into:

Code: Select all

require(JModuleHelper::getLayoutPath('mod_phocagallery_random_image'));
}
?>
so now whole module disappears when it has nothing to show.

Re: Proposal of improvements in mod_phocagallery_random_image?

Posted: 26 Jan 2009, 15:13
by Jan
Ok, thank you, I will do these changes in next version.

Thank you, Jan