Hi,
This query randomly generates huge load on almost every page on my gallery: (I say randomly cause sometimes it load in 0.1 sec, but in some cases it takes up to 4 seconds to load.)
[55] => SELECT COUNT(*) FROM cpg_pictures WHERE approved = 'NO' (3.162s)
Found in functions.inc.php // get number of pending approvals
/**
* cpg_get_pending_approvals()
*
* @return
**/
function cpg_get_pending_approvals()
{
global $CONFIG;
$result = cpg_db_query("SELECT COUNT(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'NO'");
if (mysql_num_rows($result) == 0) return 0;
$row = mysql_fetch_array($result);
mysql_free_result($result);
return $row[0];
}
// Return the total number of comments for a certain picture
I've attempted to remove the query but then cpg complains about ecard templates somewhere in the theme.php. Is this query strickly related to ecards & private albums and possibly comments?
For some reason this query is always slower then the query below:
[57] => SELECT COUNT(*) from cpg_pictures WHERE approved = 'YES' (0.169s)
Help would be much appreciated
Replace the function withfunction cpg_get_pending_approvals()
{
return '0';
}
instead of commenting out the query. The code that calls the function expects a number to be returned, not NULL. That number can be zero, which is being interpreted as "0 pictures need approval". You'll loose the approval admin menu item. Doesn't hurt if you're the only uploader or if you haven't enabled admin approval for your groups.
Thanks! Works like a charm. Issue solved!