[MTOS-dev] [movabletype] takayama, r1519: Implemented bugid:68746

Hirotaka Ogawa hirotaka.ogawa at gmail.com
Wed Mar 12 21:48:08 PDT 2008


Perhaps, attached patch is required in connection with:
http://bugs.movabletype.org/default.asp?69786

On Thu, Mar 13, 2008 at 12:29 PM,  <commits at code.sixapart.com> wrote:
> Implemented bugid:68746
>
>  * Rebuilding is not necessary after entries is deleted.
>
>
>  U   branches/release-31/lib/MT/App/CMS.pm
>  U   branches/release-31/lib/MT/CMS/Common.pm
>  U   branches/release-31/lib/MT/CMS/Entry.pm
>  U   branches/release-31/lib/MT/Core.pm
>  U   branches/release-31/tmpl/cms/list_entry.tmpl
>
>
>  Modified: branches/release-31/lib/MT/App/CMS.pm
>  ===================================================================
>  --- branches/release-31/lib/MT/App/CMS.pm       2008-03-12 17:29:18 UTC (rev 1518)
>  +++ branches/release-31/lib/MT/App/CMS.pm       2008-03-13 03:29:36 UTC (rev 1519)
>  @@ -101,6 +101,9 @@
>          'save_entry'   => "${pkg}Entry::save",
>          'save_role'    => "${pkg}User::save_role",
>
>  +        ## Delete
>  +        'delete_entry' => "${pkg}Entry::delete",
>  +
>          ## List actions
>          'enable_object'  => "${pkg}User::enable",
>          'disable_object' => "${pkg}User::disable",
>  @@ -3290,6 +3293,21 @@
>      \@data;
>   }
>
>  +sub publish_error {
>  +    my $app = shift;
>  +    my ($msg) = @_;
>  +    if (defined $app->errstr) {
>  +        require MT::Log;
>  +        $app->log({
>  +            message => $app->translate("Error during publishing: [_1]", (defined $msg ? $msg : $app->errstr)),
>  +            class => "system",
>  +            level => MT::Log::ERROR(),
>  +            category => "publish",
>  +        })
>  +    }
>  +    return undef;
>  +}
>  +
>   1;
>   __END__
>
>
>  Modified: branches/release-31/lib/MT/CMS/Common.pm
>  ===================================================================
>  --- branches/release-31/lib/MT/CMS/Common.pm    2008-03-12 17:29:18 UTC (rev 1518)
>  +++ branches/release-31/lib/MT/CMS/Common.pm    2008-03-13 03:29:36 UTC (rev 1519)
>  @@ -983,35 +983,6 @@
>                  }
>              }
>          }
>  -        elsif ( $type eq 'entry' ) {
>  -            if ( $app->config('DeleteFilesAtRebuild') ) {
>  -                $app->publisher->remove_entry_archive_file(
>  -                    Entry       => $obj,
>  -                    ArchiveType => 'Individual'
>  -                );
>  -                require MT::Blog;
>  -                my $blog = MT::Blog->load($blog_id);
>  -                my $at   = $blog->archive_type;
>  -                if ( $at && $at ne 'None' ) {
>  -                    my @at = split (/,/, $at);
>  -                    for my $target (@at) {
>  -                        my $archiver = $app->publisher->archiver($target);
>  -                        next unless $archiver;
>  -                        my $entries_count = $archiver->archive_entries_count;
>  -                        if ($entries_count){
>  -                            my $count = $entries_count->($blog, $target, $obj);
>  -                            if ( $count == 1 ) {
>  -                                $app->publisher->remove_entry_archive_file(
>  -                                    Entry       => $obj,
>  -                                    ArchiveType => $target
>  -                                );
>  -                            }
>  -                        }
>  -                    }
>  -                }
>  -            }
>  -
>  -        }
>          elsif ( $type eq 'page' ) {
>              if ( $app->config('DeleteFilesAtRebuild') ) {
>                  $app->publisher->remove_entry_archive_file(
>
>  Modified: branches/release-31/lib/MT/CMS/Entry.pm
>  ===================================================================
>  --- branches/release-31/lib/MT/CMS/Entry.pm     2008-03-12 17:29:18 UTC (rev 1518)
>  +++ branches/release-31/lib/MT/CMS/Entry.pm     2008-03-13 03:29:36 UTC (rev 1519)
>  @@ -693,6 +693,7 @@
>      $param{can_republish}       = $blog_id ? $perms->can_rebuild : 1;
>      $param{is_power_edit}       = $is_power_edit;
>      $param{saved_deleted}       = $q->param('saved_deleted');
>  +    $param{no_rebuild}          = $q->param('no_rebuild');
>      $param{saved}               = $q->param('saved');
>      $param{limit}               = $limit;
>      $param{offset}              = $offset;
>  @@ -2290,4 +2291,104 @@
>      }
>   }
>
>  +sub delete {
>  +    my $app = shift;
>  +    $app->validate_magic() or return;
>  +
>  +    require MT::Blog;
>  +    my $q       = $app->param;
>  +    my $blog_id = $q->param('blog_id');
>  +    my $blog    = MT::Blog->load($blog_id);
>  +
>  +    for my $id ( $q->param('id') ) {
>  +        my $can_background =
>  +          ( $blog->count_static_templates('Individual') == 0
>  +              || MT::Util->launch_background_tasks() ) ? 1 : 0;
>  +
>  +        my $class = $app->model("entry");
>  +        my $obj   = $class->load($id);
>  +        return $app->call_return unless $obj;
>  +
>  +        $app->run_callbacks( 'cms_delete_permission_filter.entry', $app, $obj )
>  +          || return $app->error(
>  +            $app->translate( "Permission denied: [_1]", $app->errstr() ) );
>  +
>  +        if ( $app->config('DeleteFilesAtRebuild') ) {
>  +
>  +            # Remove related archive file if that include this entry only.
>  +            my $at = $blog->archive_type;
>  +            if ( $at && $at ne 'None' ) {
>  +                my @at = split( /,/, $at );
>  +                for my $target (@at) {
>  +                    my $archiver = $app->publisher->archiver($target);
>  +                    next unless $archiver;
>  +                    my $count =
>  +                        $archiver->can('archive_entries_count')
>  +                      ? $archiver->archive_entries_count( $blog, $target, $obj )
>  +                      : 0;
>  +                    if ( $count == 1 || $target eq 'Individual' ) {
>  +                        $app->publisher->remove_entry_archive_file(
>  +                            Entry       => $obj,
>  +                            ArchiveType => $target
>  +                        );
>  +                    }
>  +                }
>  +            }
>  +        }
>  +
>  +        # Remove object from database
>  +        $obj->remove()
>  +          or return $app->errtrans(
>  +            'Removing [_1] failed: [_2]',
>  +            $app->translate('entry'),
>  +            $obj->errstr
>  +          );
>  +        $app->run_callbacks( 'cms_post_delete.entry', $app, $obj );
>  +
>  +        if ( $app->config('RebuildAtDelete') ) {
>  +            if ($can_background) {
>  +                my $res = MT::Util::start_background_task(
>  +                    sub {
>  +                        $app->rebuild_entry(
>  +                            Entry             => $obj,
>  +                            BuildDependencies => 1,
>  +                            BuildIndexes      => 1,
>  +                            BuildArchives     => 1,
>  +                        ) or return $app->publish_error();
>  +                        $app->run_callbacks( 'rebuild', $blog );
>  +                        1;
>  +                    }
>  +                );
>  +            }
>  +            else {
>  +                $app->rebuild_entry(
>  +                    Entry             => $obj,
>  +                    BuildDependencies => 1,
>  +                    BuildIndexes      => 1,
>  +                    BuildArchives     => 1,
>  +                ) or return $app->publish_error();
>  +                $app->run_callbacks( 'rebuild', $blog );
>  +            }
>  +        }
>  +    }
>  +
>  +    $app->add_return_arg( saved_deleted => 1 );
>  +    if ( $q->param('is_power_edit') ) {
>  +        $app->add_return_arg( is_power_edit => 1 );
>  +    }
>  +
>  +    if ( $app->config('RebuildAtDelete') ) {
>  +        $app->add_return_arg( no_rebuild => 1 );
>  +        my %params = (
>  +            is_full_screen  => 1,
>  +            redirect_target => $app->app_path
>  +              . $app->script . '?'
>  +              . $app->return_args,
>  +        );
>  +        return $app->load_tmpl( 'rebuilding.tmpl', \%params );
>  +    }
>  +
>  +    return $app->call_return();
>  +}
>  +
>   1;
>
>  Modified: branches/release-31/lib/MT/Core.pm
>  ===================================================================
>  --- branches/release-31/lib/MT/Core.pm  2008-03-12 17:29:18 UTC (rev 1518)
>  +++ branches/release-31/lib/MT/Core.pm  2008-03-13 03:29:36 UTC (rev 1519)
>  @@ -464,6 +464,7 @@
>                  },
>              },
>              'DeleteFilesAtRebuild'      => { default => 1, },
>  +            'RebuildAtDelete'           => { default => 1, },
>              'MaxTagAutoCompletionItems' => { default => 10000, },
>              'NewUserAutoProvisioning' =>
>                { handler => \&NewUserAutoProvisioning, },
>
>  Modified: branches/release-31/tmpl/cms/list_entry.tmpl
>  ===================================================================
>  --- branches/release-31/tmpl/cms/list_entry.tmpl        2008-03-12 17:29:18 UTC (rev 1518)
>  +++ branches/release-31/tmpl/cms/list_entry.tmpl        2008-03-13 03:29:36 UTC (rev 1519)
>  @@ -15,6 +15,8 @@
>      <div id="msg-container">
>      <mt:if name="dynamic_all">
>          <mt:setvar name="rebuild" value="">
>  +    <mt:elseif name="no_rebuild">
>  +        <mt:setvar name="rebuild" value="">
>      <mt:else>
>          <mt:if name="blog_id">
>              <mt:setvar name="rebuild" value="all">
>
>
>  _______________________________________________
>  MTOS-commits mailing list
>  MTOS-commits at sixapart.com
>  http://www.sixapart.com/mailman/listinfo/mtos-commits
>



-- 
Hirotaka Ogawa makes no sense.
http://as-is.net/blog/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mtos-r1519-delete-entry-fix.patch
Type: text/x-patch
Size: 1487 bytes
Desc: not available
Url : http://www.sixapart.com/pipermail/mtos-dev/attachments/20080313/9d093d2f/attachment.bin 


More information about the MTOS-dev mailing list