Show
Ignore:
Timestamp:
07/09/08 02:47:30 (17 months ago)
Author:
takayama
Message:

Fixed BugId:80382
* Changed to removes fileinfo records when entry was deleted.

  • CMS, Atom and XMLRPC
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/release-41/lib/MT/CMS/Entry.pm

    r2548 r2737  
    21262126    my $app = shift; 
    21272127    $app->validate_magic() or return; 
    2128  
    21292128    require MT::Blog; 
    21302129    my $q       = $app->param; 
     
    21382137 
    21392138    my %rebuild_recip; 
    2140     my $at = $blog->archive_type; 
    2141     my @at; 
    2142     if ( $at && $at ne 'None' ) { 
    2143         my @at_orig = split( /,/, $at ); 
    2144         @at = grep { $_ ne 'Individual' && $_ ne 'Page' } @at_orig; 
    2145     } 
    2146  
    21472139    for my $id ( $q->param('id') ) { 
    21482140        my $class = $app->model("entry"); 
     
    21542146            $app->translate( "Permission denied: [_1]", $app->errstr() ) ); 
    21552147 
    2156         # Remove Individual archive file. 
    2157         if ( $app->config('DeleteFilesAtRebuild') ) { 
    2158             $app->publisher->remove_entry_archive_file( Entry => $obj, ); 
    2159         } 
    2160         if (   $app->config('RebuildAtDelete') 
    2161             || $app->config('DeleteFilesAtRebuild') ) 
    2162         { 
    2163             for my $at (@at) { 
    2164                 my $archiver = $app->publisher->archiver($at); 
    2165                 next unless $archiver; 
    2166  
    2167                 # Remove archive file if archive file has not entries. 
    2168                 my $to_delete = 
    2169                     ( $archiver->archive_entries_count( $blog, $at, $obj ) == 1 ) ? 1 : 0 
    2170                     if $archiver->can('archive_entries_count'); 
    2171                 if ( $to_delete && $app->config('DeleteFilesAtRebuild') ) { 
    2172                      $app->publisher->remove_entry_archive_file( 
    2173                          Entry       => $obj, 
    2174                          ArchiveType => $at 
    2175                      ); 
    2176                 } 
    2177                 next if $to_delete; 
    2178  
    2179                 # Make rebuild recip 
    2180                 if ( $app->config('RebuildAtDelete') ) { 
    2181                     my ( $start, $end ) = $archiver->date_range( $obj->authored_on ) 
    2182                         if $archiver->date_based() && $archiver->can('date_range'); 
    2183  
    2184                     if ( $archiver->category_based() ) { 
    2185                         my $categories = $obj->categories(); 
    2186                         for my $cat (@$categories) { 
    2187                             if ( $archiver->date_based() ) { 
    2188                                 $rebuild_recip{$at}{ $cat->id }{ $start . $end } 
    2189                                   {'Start'} = $start; 
    2190                                 $rebuild_recip{$at}{ $cat->id }{ $start . $end } 
    2191                                   {'End'} = $end; 
    2192                                 $rebuild_recip{$at}{ $cat->id }{ $start . $end } 
    2193                                   {'File'} = 
    2194                                   MT::Util::archive_file_for( $obj, $blog, $at, 
    2195                                     $cat, undef, undef, undef ); 
    2196                             } 
    2197                             else { 
    2198                                 $rebuild_recip{$at}{ $cat->id }{id} = $cat->id; 
    2199                                 $rebuild_recip{$at}{ $cat->id }{'File'} = 
    2200                                   MT::Util::archive_file_for( $obj, $blog, $at, 
    2201                                     $cat, undef, undef, undef ); 
    2202                             } 
    2203                         } 
    2204                     } 
    2205                     elsif ( $archiver->author_based() ) { 
    2206                         if ( $archiver->date_based() ) { 
    2207                             $rebuild_recip{$at}{ $obj->author->id }{ $start . $end } 
    2208                               {'Start'} = $start; 
    2209                             $rebuild_recip{$at}{ $obj->author->id }{ $start . $end } 
    2210                               {'End'} = $end; 
    2211                             $rebuild_recip{$at}{ $obj->author->id }{ $start . $end } 
    2212                               {'File'} = 
    2213                               MT::Util::archive_file_for( $obj, $blog, $at, undef, 
    2214                                 undef, undef, $obj->author ); 
    2215                         } 
    2216                         else { 
    2217                             $rebuild_recip{$at}{ $obj->author->id }{id} = 
    2218                               $obj->author->id; 
    2219                             $rebuild_recip{$at}{ $obj->author->id }{'File'} = 
    2220                               MT::Util::archive_file_for( $obj, $blog, $at, undef, 
    2221                                 undef, undef, $obj->author ); 
    2222                         } 
    2223                     } 
    2224                     elsif ( $archiver->date_based() ) { 
    2225                         $rebuild_recip{$at}{ $start . $end }{'Start'} = $start; 
    2226                         $rebuild_recip{$at}{ $start . $end }{'End'}   = $end; 
    2227                         $rebuild_recip{$at}{ $start . $end }{'File'} = 
    2228                           MT::Util::archive_file_for( $obj, $blog, $at, undef, 
    2229                             undef, undef, undef ); 
    2230                     } 
    2231                     if ( my $prev = $obj->previous(1) ) { 
    2232                         $rebuild_recip{Individual}{ $prev->id }{id} = $prev->id; 
    2233                         $rebuild_recip{Individual}{ $prev->id }{'File'} = 
    2234                           MT::Util::archive_file_for( $prev, $blog, 'Individual', 
    2235                             undef, undef, undef, undef ); 
    2236                     } 
    2237                     if ( my $next = $obj->next(1) ) { 
    2238                         $rebuild_recip{Individual}{ $next->id }{id} = $next->id; 
    2239                         $rebuild_recip{Individual}{ $next->id }{'File'} = 
    2240                           MT::Util::archive_file_for( $next, $blog, 'Individual', 
    2241                             undef, undef, undef, undef ); 
    2242                     } 
    2243                 } 
    2244             } 
    2245         } 
     2148        my %recip = $app->publisher->rebuild_deleted_entry( 
     2149            Entry => $obj, 
     2150            Blog  => $blog); 
    22462151 
    22472152        # Remove object from database