Changeset 4730


Ignore:
Timestamp:
01/23/10 23:56:11 (9 years ago)
Author:
plg
Message:

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.

Location:
branches/2.0/admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/admin/element_set_global.php

    r4495 r4730  
    9292      if (count($deletables) > 0) 
    9393      { 
    94         // what will be the categories to update? (to avoid orphan on 
    95         // representative_picture_id) 
    96         $query = ' 
    97 SELECT 
    98     category_id 
    99   FROM '.IMAGE_CATEGORY_TABLE.' 
    100   WHERE image_id IN ('.implode(',', $deletables).') 
    101 ;'; 
    102         $categories_to_update = array_from_query($query, 'category_id'); 
    103            
    10494        $physical_deletion = true; 
    10595        delete_elements($deletables, $physical_deletion); 
    106  
    107         update_category($categories_to_update); 
    10896 
    10997        array_push( 
  • branches/2.0/admin/include/functions.php

    r4617 r4730  
    235235  pwg_query($query); 
    236236 
     237  // are the photo used as category representant? 
     238  $query = ' 
     239SELECT 
     240    id 
     241  FROM '.CATEGORIES_TABLE.' 
     242  WHERE representative_picture_id IN ( 
     243'.wordwrap(implode(', ', $ids), 80, "\n").') 
     244;'; 
     245  $category_ids = array_from_query($query, 'id'); 
     246  if (count($category_ids) > 0) 
     247  { 
     248    update_category($category_ids); 
     249  } 
     250   
    237251  trigger_action('delete_elements', $ids); 
    238252} 
Note: See TracChangeset for help on using the changeset viewer.