daily pastebin goal
20%
SHARE
TWEET

Untitled

a guest May 16th, 2018 107 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Movable Type (r) Open Source (C) 2001-2008 Six Apart, Ltd.
  2. # This program is distributed under the terms of the
  3. # GNU General Public License, version 2.
  4. #
  5. # $Id: WeblogPublisher.pm 2051 2008-04-24 03:02:29Z fumiakiy $
  6.  
  7. package MT::WeblogPublisher;
  8.  
  9. use strict;
  10. use base qw( MT::ErrorHandler Exporter );
  11. our @EXPORT = qw(ArchiveFileTemplate ArchiveType);
  12.  
  13. #
  14. # [... SNIP ...]
  15. #
  16.  
  17. sub new {
  18.     my $class = shift;
  19.     my $this  = {@_};
  20.     my $cfg   = MT->config;    
  21.                                                     ########################################################
  22.     if ( !exists $this->{start_time} ) {            # Time is initialized here which is nearly at the
  23.         $this->{start_time} = time;                 # beginning of MT initialization.  Since this never
  24.     }                                               # happens again in a persistent environment, start_time
  25.     if ( !exists $this->{NoTempFiles} ) {           # will always be less than mod_time after a single rebuild.
  26.         $this->{NoTempFiles} = $cfg->NoTempFiles;   ########################################################
  27.     }
  28.     if ( !exists $this->{PublishCommenterIcon} ) {
  29.         $this->{PublishCommenterIcon} = $cfg->PublishCommenterIcon;
  30.     }
  31.     bless $this, $class;
  32.     $this->init();
  33.     $this;
  34. }
  35.  
  36. #
  37. # [... SNIP ...]
  38. #
  39.  
  40. # This method performs the work of publishing Category,
  41. # Author, Date-based, Individual and Page archives
  42. sub rebuild_file {
  43.     my $mt = shift;
  44.     my ( $blog, $root_path, $map, $at, $ctx, $cond, $build_static, %args )
  45.       = @_;
  46.  
  47.     my $finfo;
  48.     my $archiver = $mt->archiver($at);
  49.     my ( $entry, $start, $end, $category, $author );
  50.  
  51.     if ( $finfo = $args{FileInfo} ) {
  52.         $args{Author}   = $finfo->author_id   if $finfo->author_id;
  53.         $args{Category} = $finfo->category_id if $finfo->category_id;
  54.         $args{Entry}    = $finfo->entry_id    if $finfo->entry_id;
  55.         $map ||= MT::TemplateMap->load( $finfo->templatemap_id );
  56.         $at  ||= $finfo->archive_type;
  57.         if ( $finfo->startdate ) {
  58.             if ( ( $start, $end ) = $archiver->date_range($finfo->startdate) ) {
  59.                 $args{StartDate} = $start;
  60.                 $args{EndDate}   = $end;
  61.             }
  62.         }
  63.     }
  64.  
  65.     # Calculate file path and URL for the new entry.
  66.     my $file = File::Spec->catfile( $root_path, $map->{__saved_output_file} );
  67.  
  68.     ## Untaint. We have to assume that we can trust the user's setting of
  69.     ## the archive_path, and nothing else is based on user input.
  70.     ($file) = $file =~ /(.+)/s;
  71.  
  72.     # compare file modification time to start of build process. if it          
  73.     # is greater than the start_time, then we shouldn't need to build this      
  74.     # file again
  75.     my $fmgr = $blog->file_mgr;
  76.     if (my $mod_time = $fmgr->file_mod_time($file)) {       # <<<<<<<<<<<<<<  This section here is what's
  77.         return 1 if $mod_time >= $mt->start_time;           # <<<<<<<<<<<<<<  causing the issue.
  78.     }                                                       # <<<<<<<<<<<<<<  
  79.  
  80.     #
  81.     # Etc.  Once a template is rebuilt, it never makes
  82.     # it past here again in a persistent environment
  83.     #
  84.  
  85.     # [...SNIP...]
  86. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top