diff options
author | plegall <plg@piwigo.org> | 2010-01-23 22:56:11 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2010-01-23 22:56:11 +0000 |
commit | bec299bc363f09c006eea80fe8cd25bddf0d638d (patch) | |
tree | 8214b36466017bdcfd9f7602ab86c204e1e24e5d /admin/include/functions.php | |
parent | ac0929fe84f8fdace0707192b3e7a5c36de53475 (diff) |
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/branches/2.0@4730 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | admin/include/functions.php | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/admin/include/functions.php b/admin/include/functions.php index 018fd5021..c186e1ed8 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -234,6 +234,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); } |