Changeset 26557


Ignore:
Timestamp:
Jan 9, 2014, 8:44:12 PM (7 years ago)
Author:
plg
Message:

bug 2512 fixed: safely remove photos in community pending list when photo is
deleted (outside Community).

Location:
extensions/community
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/community/admin_pendings.php

    r23744 r26557  
    121121// | pending photos list                                                   |
    122122// +-----------------------------------------------------------------------+
     123
     124// just in case (because we had a bug in Community plugin up to version
     125// 2.5.c) let's remove rows in community_pendings table if related photos
     126// has been deleted
     127$query = '
     128SELECT
     129    image_id
     130  FROM '.COMMUNITY_PENDINGS_TABLE.'
     131    LEFT JOIN '.IMAGES_TABLE.' ON id = image_id
     132  WHERE id IS NULL
     133;';
     134$to_delete = array_from_query($query, 'image_id');
     135
     136if (count($to_delete) > 0)
     137{
     138  $query = '
     139DELETE
     140  FROM '.COMMUNITY_PENDINGS_TABLE.'
     141  WHERE image_id IN ('.implode(',', $to_delete).')
     142;';
     143  pwg_query($query);
     144}
    123145
    124146$list = array();
  • extensions/community/main.inc.php

    r23960 r26557  
    8585    COUNT(*)
    8686  FROM '.COMMUNITY_PENDINGS_TABLE.'
     87    JOIN '.IMAGES_TABLE.' ON image_id = id
    8788  WHERE state = \'moderation_pending\'
    8889;';
     
    644645}
    645646
     647add_event_handler('delete_elements', 'community_delete_elements');
     648function community_delete_elements($image_ids)
     649{
     650  $query = '
     651DELETE
     652  FROM '.COMMUNITY_PENDINGS_TABLE.'
     653  WHERE image_id IN ('.implode(',', $image_ids).')
     654;';
     655  pwg_query($query);
     656}
     657
    646658add_event_handler('invalidate_user_cache', 'community_refresh_cache_update_time');
    647659function community_refresh_cache_update_time()
Note: See TracChangeset for help on using the changeset viewer.