aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2010-01-23 22:57:01 +0000
committerplegall <plg@piwigo.org>2010-01-23 22:57:01 +0000
commit4cc6d4172ecb82cba40dff2c63a91580646a647f (patch)
tree2d45e9fee24be7c048853b565498c14e0514ddc1 /admin
parent4e26a5480e40e784d65f809443b61b860444b974 (diff)
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
Diffstat (limited to '')
-rw-r--r--admin/element_set_global.php12
-rw-r--r--admin/include/functions.php14
2 files changed, 14 insertions, 12 deletions
diff --git a/admin/element_set_global.php b/admin/element_set_global.php
index 2b7b728ac..1a74e1c42 100644
--- a/admin/element_set_global.php
+++ b/admin/element_set_global.php
@@ -85,21 +85,9 @@ SELECT
if (count($deletables) > 0)
{
- // what will be the categories to update? (to avoid orphan on
- // representative_picture_id)
- $query = '
-SELECT
- category_id
- FROM '.IMAGE_CATEGORY_TABLE.'
- WHERE image_id IN ('.implode(',', $deletables).')
-;';
- $categories_to_update = array_from_query($query, 'category_id');
-
$physical_deletion = true;
delete_elements($deletables, $physical_deletion);
- update_category($categories_to_update);
-
array_push(
$page['infos'],
sprintf(
diff --git a/admin/include/functions.php b/admin/include/functions.php
index b0d0c4325..881a87e5b 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -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);
}