mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-06-02 04:15:05 +02:00
bug 2105 : Browsing tags is slow if tags contains many photos
git-svn-id: http://piwigo.org/svn/trunk@8726 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -231,23 +231,18 @@ SELECT DISTINCT(id)
|
||||
{
|
||||
$query .= "\n AND ".$images_where;
|
||||
}
|
||||
if (empty($tag_items) or $search['mode']=='AND')
|
||||
{ // directly use forbidden and order by
|
||||
$query .= $forbidden.'
|
||||
$query .= $forbidden.'
|
||||
'.$conf['order_by'];
|
||||
}
|
||||
$items = array_from_query($query, 'id');
|
||||
}
|
||||
|
||||
if ( !empty($tag_items) )
|
||||
{
|
||||
$need_permission_check = false;
|
||||
switch ($search['mode'])
|
||||
{
|
||||
case 'AND':
|
||||
if (empty($search_clause))
|
||||
{
|
||||
$need_permission_check = true;
|
||||
$items = $tag_items;
|
||||
}
|
||||
else
|
||||
@@ -263,27 +258,8 @@ SELECT DISTINCT(id)
|
||||
$tag_items
|
||||
)
|
||||
);
|
||||
if ( $before_count < count($items) )
|
||||
{
|
||||
$need_permission_check = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ($need_permission_check and count($items) )
|
||||
{
|
||||
$query = '
|
||||
SELECT DISTINCT(id)
|
||||
FROM '.IMAGES_TABLE.' i
|
||||
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
|
||||
WHERE id IN ('.implode(',', $items).') '.$forbidden;
|
||||
if (!empty($images_where))
|
||||
{
|
||||
$query .= "\n AND ".$images_where;
|
||||
}
|
||||
$query .= '
|
||||
'.$conf['order_by'];
|
||||
$items = array_from_query($query, 'id');
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
|
||||
Reference in New Issue
Block a user