*
* @file
* @author Brion Vibber <brion at pobox.com>
- * @ingrouo maintenance
+ * @ingroup maintenance
*/
$options = array( 'missing', 'dry-run' );
-require_once( dirname(__FILE__) . '/commandLine.inc' );
+require_once( dirname( __FILE__ ) . '/commandLine.inc' );
require_once( 'FiveUpgrade.inc' );
class ImageBuilder extends FiveUpgrade {
- function ImageBuilder( $dryrun = false ) {
+ function __construct( $dryrun = false ) {
parent::FiveUpgrade();
$this->maxLag = 10; # if slaves are lagged more than 10 secs, wait
function progress( $updated ) {
$this->updated += $updated;
$this->processed++;
- if( $this->processed % 100 != 0 ) {
+ if ( $this->processed % 100 != 0 ) {
return;
}
$portion = $this->processed / $this->count;
$sql = "SELECT * FROM $tableName";
$result = $this->dbr->query( $sql, $fname );
- while( $row = $this->dbr->fetchObject( $result ) ) {
+ while ( $row = $this->dbr->fetchObject( $result ) ) {
$update = call_user_func( $callback, $row, null );
- if( $update ) {
+ if ( $update ) {
$this->progress( 1 );
} else {
$this->progress( 0 );
}
}
$this->log( "Finished $table... $this->updated of $this->processed rows updated" );
- $this->dbr->freeResult( $result );
}
function buildImage() {
function checkMissingImage( $fullpath ) {
$fname = 'ImageBuilder::checkMissingImage';
$filename = wfBaseName( $fullpath );
- if( is_dir( $fullpath ) ) {
+ if ( is_dir( $fullpath ) ) {
return;
}
- if( is_link( $fullpath ) ) {
+ if ( is_link( $fullpath ) ) {
$this->log( "skipping symlink at $fullpath" );
return;
}
array( 'img_name' => $filename ),
$fname );
- if( $row ) {
+ if ( $row ) {
// already known, move on
return;
} else {
}
function addMissingImage( $filename, $fullpath ) {
- $fname = 'ImageBuilder::addMissingImage';
-
$timestamp = $this->dbw->timestamp( filemtime( $fullpath ) );
global $wgContLang;
$altname = $wgContLang->checkTitleEncoding( $filename );
- if( $altname != $filename ) {
- if( $this->dryrun ) {
+ if ( $altname != $filename ) {
+ if ( $this->dryrun ) {
$filename = $altname;
$this->log( "Estimating transcoding... $altname" );
} else {
}
}
- if( $filename == '' ) {
+ if ( $filename == '' ) {
$this->log( "Empty filename for $fullpath" );
return;
}
if ( !$this->dryrun ) {
$file = wfLocalFile( $filename );
- if ( !$file->recordUpload( '', '(recovered file, missing upload log entry)', '', '', '',
+ if ( !$file->recordUpload( '', '(recovered file, missing upload log entry)', '', '', '',
false, $timestamp ) )
{
$this->log( "Error uploading file $fullpath" );
}
$builder = new ImageBuilder( isset( $options['dry-run'] ) );
-if( isset( $options['missing'] ) ) {
+if ( isset( $options['missing'] ) ) {
$builder->crawlMissing();
} else {
$builder->build();