merge r4730 from branch 2.0 to trunk

bug 1396: when a photo was deleted, the code to avoid orphans as category
representative was 1) wrong (because a photo doesn't have to belong to a
category to represent it) 2) at the wrong place.


git-svn-id: http://piwigo.org/svn/trunk@4731 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
plegall 2010-01-23 22:57:01 +00:00
commit 4cc6d4172e
2 changed files with 14 additions and 12 deletions

View file

@ -262,6 +262,20 @@ DELETE FROM '.IMAGES_TABLE.'
;';
pwg_query($query);
// are the photo used as category representant?
$query = '
SELECT
id
FROM '.CATEGORIES_TABLE.'
WHERE representative_picture_id IN (
'.wordwrap(implode(', ', $ids), 80, "\n").')
;';
$category_ids = array_from_query($query, 'id');
if (count($category_ids) > 0)
{
update_category($category_ids);
}
trigger_action('delete_elements', $ids);
}