Show
Ignore:
Timestamp:
04/05/08 01:31:43 (20 months ago)
Author:
bchoate
Message:

Changes to update type-based touches prior to any rebuilding. Added 'pre_build', 'post_build' callbacks that wrap entire build process (pre_build is called at start of multi-request build process; post_build is called at the end). Added a total publish time message at end of build process. BugId:74814

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/release-33/lib/MT/CMS/Blog.pm

    r1776 r1778  
    531531        } 
    532532    } 
     533    $app->run_callbacks('post_build'); 
    533534    $app->call_return; 
    534535} 
     
    541542    require MT::Blog; 
    542543    my $q             = $app->param; 
    543     my $blog_id       = $q->param('blog_id'); 
     544    my $start_time    = $q->param('start_time'); 
     545 
     546    if ( ! $start_time ) { 
     547        # start of build; invoke callback 
     548        $app->run_callbacks('pre_build'); 
     549        $start_time = time; 
     550    } 
     551 
     552    my $blog_id       = int($q->param('blog_id')); 
     553    return $app->errtrans("Invalid request.") unless $blog_id; 
     554 
    544555    my $blog          = MT::Blog->load($blog_id); 
    545556    my $order         = $q->param('type'); 
     
    550561    my $archiver      = $app->publisher->archiver($type); 
    551562    my $archive_label = $archiver ? $archiver->archive_label : ''; 
     563 
    552564    $archive_label = $app->translate($type) unless $archive_label; 
    553565    $archive_label = $archive_label->() if ( ref $archive_label ) eq 'CODE'; 
     
    556568    my $offset = 0; 
    557569    my ($total) = $q->param('total'); 
    558  
    559     ## Tells MT::_rebuild_entry_archive_type to cache loaded templates so 
    560     ## that each template is only loaded once. 
    561     $app->{cache_templates} = 1; 
    562570 
    563571    my ($tmpl_saved); 
     
    774782            offset          => $offset, 
    775783            complete        => $complete, 
     784            start_time      => $start_time, 
    776785            incomplete      => 100 - $complete, 
    777786            entry_id        => scalar $q->param('entry_id'), 
     
    783792    } 
    784793    else { 
     794        $app->run_callbacks( 'post_build' ); 
    785795        if ( $q->param('entry_id') ) { 
    786796            require MT::Entry; 
     
    809819            } 
    810820            my %param = ( 
    811                 all          => $all, 
    812                 type         => $archive_label, 
    813                 is_one_index => $is_one_index, 
    814                 is_entry     => $is_entry, 
    815                 archives     => $type ne 'index', 
     821                all             => $all, 
     822                type            => $archive_label, 
     823                is_one_index    => $is_one_index, 
     824                is_entry        => $is_entry, 
     825                archives        => $type ne 'index', 
     826                start_timestamp => MT::Util::epoch2ts($blog, $start_time), 
     827                total_time      => time - $start_time, 
    816828            ); 
    817829            if ($is_one_index) { 
     
    838850            } 
    839851            else {    # popup--just go to cnfrmn. page 
    840                 $app->run_callbacks( 'rebuild', $blog ); 
    841852                return $app->load_tmpl( 'popup/rebuilt.tmpl', \%param ); 
    842853            } 
     
    854865    my $app           = shift; 
    855866    my $q             = $app->param; 
     867    my $start_time    = $q->param('start_time'); 
     868 
     869    if ( ! $start_time ) { 
     870        # start of build; invoke callback 
     871        $app->run_callbacks('pre_build'); 
     872        $start_time = time; 
     873    } 
     874 
    856875    my $type          = $q->param('type'); 
    857876    my $next          = $q->param('next') || 0; 
     
    906925        build_next      => $next, 
    907926        total           => $total, 
     927        start_time      => $start_time, 
    908928        complete        => 0, 
    909929        incomplete      => 100,