* Mapping from type option to log type and actions.
* @var array
*/
- private static $typeMappings = array(
- 'created' => array(
- 'upload' => array( 'upload' ),
- 'import' => array( 'upload', 'interwiki' ),
- ),
- 'deleted' => array(
- 'delete' => array( 'delete', 'revision' ),
- 'suppress' => array( 'delete', 'revision' ),
- ),
- 'modified' => array(
- 'upload' => array( 'overwrite', 'revert' ),
- 'move' => array( 'move', 'move_redir' ),
- ),
- );
+ private static $typeMappings = [
+ 'created' => [
+ 'upload' => [ 'upload' ],
+ 'import' => [ 'upload', 'interwiki' ],
+ ],
+ 'deleted' => [
+ 'delete' => [ 'delete', 'revision' ],
+ 'suppress' => [ 'delete', 'revision' ],
+ ],
+ 'modified' => [
+ 'upload' => [ 'overwrite', 'revert' ],
+ 'move' => [ 'move', 'move_redir' ],
+ ],
+ ];
/**
* @var string
public function __construct() {
parent::__construct();
- $this->mDescription = "Scan the logging table and purge files and thumbnails.";
+ $this->addDescription( 'Scan the logging table and purge files and thumbnails.' );
$this->addOption( 'starttime', 'Starting timestamp', true, true );
$this->addOption( 'endtime', 'Ending timestamp', true, true );
$this->addOption( 'type', 'Comma-separated list of types of changes to send purges for (' .
}
// Route all HTCP messages to provided host:port
- $wgHTCPRouting = array(
- '' => array( 'host' => $parts[0], 'port' => $parts[1] ),
- );
+ $wgHTCPRouting = [
+ '' => [ 'host' => $parts[0], 'port' => $parts[1] ],
+ ];
$this->verbose( "HTCP broadcasts to {$parts[0]}:{$parts[1]}\n" );
}
$res = $dbr->select(
'logging',
- array( 'log_title', 'log_timestamp', 'log_params' ),
- array(
+ [ 'log_title', 'log_timestamp', 'log_params' ],
+ [
'log_namespace' => NS_FILE,
'log_type' => $logType,
'log_action' => $logActions,
'log_timestamp >= ' . $dbr->addQuotes( $this->startTimestamp ),
'log_timestamp <= ' . $dbr->addQuotes( $this->endTimestamp ),
- ),
+ ],
__METHOD__
);
// Purge current version and any versions in oldimage table
$file->purgeCache();
- $file->purgeHistory();
if ( $logType === 'delete' ) {
// If there is an orphaned storage file... delete it
$dpath = $this->getDeletedPath( $repo, $file );
if ( $repo->fileExists( $dpath ) ) {
// Sanity check to avoid data loss
- $repo->getBackend()->delete( array( 'src' => $file->getPath() ) );
+ $repo->getBackend()->delete( [ 'src' => $file->getPath() ] );
$this->verbose( "Deleted orphan file: {$file->getPath()}.\n" );
} else {
$this->error( "File was not deleted: {$file->getPath()}.\n" );
$target = $params['4::target'];
$targetFile = $repo->newFile( Title::makeTitle( NS_FILE, $target ) );
$targetFile->purgeCache();
- $targetFile->purgeHistory();
$this->verbose( "Purged file {$target}; move target @{$row->log_timestamp}.\n" );
}
}
$dbr = $repo->getSlaveDB();
$res = $dbr->select(
'filearchive',
- array( 'fa_archive_name' ),
- array( 'fa_name' => $file->getName() ),
+ [ 'fa_archive_name' ],
+ [ 'fa_name' => $file->getName() ],
__METHOD__
);
$dpath = $this->getDeletedPath( $repo, $ofile );
if ( $repo->fileExists( $dpath ) ) {
// Sanity check to avoid data loss
- $repo->getBackend()->delete( array( 'src' => $ofile->getPath() ) );
+ $repo->getBackend()->delete( [ 'src' => $ofile->getPath() ] );
$this->output( "Deleted orphan file: {$ofile->getPath()}.\n" );
} else {
$this->error( "File was not deleted: {$ofile->getPath()}.\n" );