Skip to content

Instantly share code, notes, and snippets.

@alfasado
Created February 1, 2013 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alfasado/4688067 to your computer and use it in GitHub Desktop.
Save alfasado/4688067 to your computer and use it in GitHub Desktop.
Movable Type's Publish Queue
use MT;
my $mt = MT->new;
require MT::TheSchwartz::FuncMap;
require MT::TheSchwartz::Job;
require MT::FileInfo;
require MT::WeblogPublisher;
my $funcmap = MT::TheSchwartz::FuncMap->load( { funcname => 'MT::Worker::Publish' } );
return unless $funcmap;
my @jobs = MT::TheSchwartz::Job->load( { funcid => $funcmap->funcid, },
{ 'sort' => 'priority',
direction => 'ascend',
},
);
my $pub = MT::WeblogPublisher->new;
for my $job ( @jobs ) {
if ( my $key = $job->uniqkey ) {
if ( my $finfo = MT::FileInfo->load( $key ) ) {
if ( $pub->rebuild_from_fileinfo( $finfo ) ) {
$job->remove or die $job->errstr;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment