Changeset 4731


Ignore:
Timestamp:
Jan 23, 2010, 11:57:01 PM (14 years ago)
Author:
plg
Message:

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.

Location:
trunk/admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/element_set_global.php

    r4334 r4731  
    8686      if (count($deletables) > 0)
    8787      {
    88         // what will be the categories to update? (to avoid orphan on
    89         // representative_picture_id)
    90         $query = '
    91 SELECT
    92     category_id
    93   FROM '.IMAGE_CATEGORY_TABLE.'
    94   WHERE image_id IN ('.implode(',', $deletables).')
    95 ;';
    96         $categories_to_update = array_from_query($query, 'category_id');
    97          
    9888        $physical_deletion = true;
    9989        delete_elements($deletables, $physical_deletion);
    100 
    101         update_category($categories_to_update);
    10290
    10391        array_push(
  • trunk/admin/include/functions.php

    r4618 r4731  
    263263  pwg_query($query);
    264264
     265  // are the photo used as category representant?
     266  $query = '
     267SELECT
     268    id
     269  FROM '.CATEGORIES_TABLE.'
     270  WHERE representative_picture_id IN (
     271'.wordwrap(implode(', ', $ids), 80, "\n").')
     272;';
     273  $category_ids = array_from_query($query, 'id');
     274  if (count($category_ids) > 0)
     275  {
     276    update_category($category_ids);
     277  }
     278 
    265279  trigger_action('delete_elements', $ids);
    266280}
Note: See TracChangeset for help on using the changeset viewer.