diff options
author | plegall <plg@piwigo.org> | 2011-01-23 00:10:29 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2011-01-23 00:10:29 +0000 |
commit | dff8596f6603559d6b3e31a8cd54a5f4ac680cf6 (patch) | |
tree | 665c6d0a18052c282a68ba0a8e0b35b411cf898a | |
parent | 7954694d734c35a23f9c53671c31bf0dc7aacc6b (diff) |
bug 2119 fixed: no crash when calling pwg.categories.delete on an empty album
git-svn-id: http://piwigo.org/svn/trunk@8848 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | admin/include/functions.php | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/admin/include/functions.php b/admin/include/functions.php index 77879b501..409cf43a0 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -97,26 +97,29 @@ SELECT WHERE category_id IN ('.implode(',', $ids).') ;'; $image_ids_linked = array_from_query($query, 'image_id'); - - if ('delete_orphans' == $photo_deletion_mode) + + if (count($image_ids_linked) > 0) { - $query = ' + if ('delete_orphans' == $photo_deletion_mode) + { + $query = ' SELECT DISTINCT(image_id) FROM '.IMAGE_CATEGORY_TABLE.' WHERE image_id IN ('.implode(',', $image_ids_linked).') AND category_id NOT IN ('.implode(',', $ids).') ;'; - $image_ids_not_orphans = array_from_query($query, 'image_id'); - $image_ids_to_delete = array_diff($image_ids_linked, $image_ids_not_orphans); - } + $image_ids_not_orphans = array_from_query($query, 'image_id'); + $image_ids_to_delete = array_diff($image_ids_linked, $image_ids_not_orphans); + } - if ('force_delete' == $photo_deletion_mode) - { - $image_ids_to_delete = $image_ids_linked; - } + if ('force_delete' == $photo_deletion_mode) + { + $image_ids_to_delete = $image_ids_linked; + } - delete_elements($image_ids_to_delete, true); + delete_elements($image_ids_to_delete, true); + } } // destruction of the links between images and this category |