Proposal of improvements in mod_phocagallery_random_image?

Phoca Gallery modules - modules for Phoca Gallery extension
zocha
Phoca Member
Phoca Member
Posts: 23
Joined: 12 Nov 2008, 14:25

Proposal of improvements in mod_phocagallery_random_image?

Post 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.
Łukasz Indeka
Joomla VirtueMart
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48386
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Proposal of improvements in mod_phocagallery_random_image?

Post by Jan »

Ok, thank you, I will do these changes in next version.

Thank you, Jan
If you find Phoca extensions useful, please support the project
Post Reply