ApiBase::PARAM_REQUIRED => true
),
'token' => null,
- 'gettoken' => false,
+ 'gettoken' => array(
+ ApiBase::PARAM_DFLT => false,
+ ApiBase::PARAM_DEPRECATED => true,
+ ),
'expiry' => 'never',
'reason' => null,
'anononly' => false,
public function getParamDescription() {
return array(
'user' => 'Username, IP address or IP range you want to block',
- 'token' => 'A block token previously obtained through the gettoken parameter or prop=info',
+ 'token' => 'A block token previously obtained through prop=info',
'gettoken' => 'If set, a block token will be returned, and no other action will be taken',
'expiry' => 'Relative expiry time, e.g. \'5 months\' or \'2 weeks\'. If set to \'infinite\', \'indefinite\' or \'never\', the block will never expire.',
'reason' => 'Reason for block (optional)',
),
'user' => null,
'token' => null,
- 'gettoken' => false,
+ 'gettoken' => array(
+ ApiBase::PARAM_DFLT => false,
+ ApiBase::PARAM_DEPRECATED => true,
+ ),
'reason' => null,
);
}
return array(
'id' => "ID of the block you want to unblock (obtained through list=blocks). Cannot be used together with {$p}user",
'user' => "Username, IP address or IP range you want to unblock. Cannot be used together with {$p}id",
- 'token' => "An unblock token previously obtained through the gettoken parameter or {$p}prop=info",
+ 'token' => "An unblock token previously obtained through prop=info",
'gettoken' => 'If set, an unblock token will be returned, and no other action will be taken',
'reason' => 'Reason for unblock (optional)',
);
}
wfDebugLog( 'imagemove', "Got request to move {$this->name} to " . $target->getText() );
- $this->lock(); // begin
-
$batch = new LocalFileMoveBatch( $this, $target );
+
+ $this->lock(); // begin
$batch->addCurrent();
$batch->addOlds();
-
$status = $batch->execute();
+ $this->unlock(); // done
+
wfDebugLog( 'imagemove', "Finished moving {$this->name}" );
$this->purgeEverything();
- $this->unlock(); // done
-
- if ( $status->isOk() ) {
+ if ( $status->isOK() ) {
// Now switch the object
$this->title = $target;
// Force regeneration of the name and hashpath
return $this->readOnlyFatalStatus();
}
- $this->lock(); // begin
-
+ $dbw = $this->repo->getMasterDB();
$batch = new LocalFileDeleteBatch( $this, $reason, $suppress );
- $batch->addCurrent();
+ $archiveNames = array();
+ $this->lock(); // begin
+ $batch->addCurrent();
# Get old version relative paths
- $dbw = $this->repo->getMasterDB();
$result = $dbw->select( 'oldimage',
array( 'oi_archive_name' ),
array( 'oi_name' => $this->getName() ) );
foreach ( $result as $row ) {
$batch->addOld( $row->oi_archive_name );
- $this->purgeOldThumbnails( $row->oi_archive_name );
+ $archiveNames[] = $row->oi_archive_name;
}
$status = $batch->execute();
-
if ( $status->isOK() ) {
// Update site_stats
$site_stats = $dbw->tableName( 'site_stats' );
$dbw->query( "UPDATE $site_stats SET ss_images=ss_images-1", __METHOD__ );
- $this->purgeEverything();
}
-
$this->unlock(); // done
+ $this->purgeEverything();
+ foreach ( $archiveNames as $archiveName ) {
+ $this->purgeOldThumbnails( $archiveName );
+ }
+
return $status;
}
return $this->readOnlyFatalStatus();
}
- $this->lock(); // begin
-
$batch = new LocalFileRestoreBatch( $this, $unsuppress );
+ $this->lock(); // begin
if ( !$versions ) {
$batch->addAll();
} else {
$batch->addIds( $versions );
}
-
$status = $batch->execute();
-
if ( $status->isGood() ) {
$cleanupStatus = $batch->cleanup();
$cleanupStatus->successCount = 0;
$cleanupStatus->failCount = 0;
$status->merge( $cleanupStatus );
}
-
$this->unlock(); // done
return $status;
class LocalFileMoveBatch {
/**
- * @var File
+ * @var LocalFile
*/
var $file;
return $statusMove;
}
- $this->db->begin( __METHOD__ );
+ $this->file->lock(); // begin
$statusDb = $this->doDBUpdates();
wfDebugLog( 'imagemove', "Renamed {$this->file->getName()} in database: {$statusDb->successCount} successes, {$statusDb->failCount} failures" );
if ( !$statusDb->isGood() ) {
- $this->db->rollback( __METHOD__ );
+ $this->file->unlockAndRollback();
// Something went wrong with the DB updates, so remove the target files
$this->cleanupTarget( $triplets );
$statusDb->ok = false;
return $statusDb;
}
- $this->db->commit( __METHOD__ );
+ $this->file->unlock(); // done
// Everything went ok, remove the source files
$this->cleanupSource( $triplets );
}
public function get( $key ) {
- # expire old entries if any
- $this->garbageCollect();
- $db = $this->getDB();
- $tableName = $this->getTableByKey( $key );
- $row = $db->selectRow( $tableName, array( 'value', 'exptime' ),
- array( 'keyname' => $key ), __METHOD__ );
+ $values = $this->getBatch( array( $key ) );
+ return $values[$key];
+ }
- if ( !$row ) {
- $this->debug( 'get: no matching rows' );
- return false;
+ public function getBatch( array $keys ) {
+ $values = array(); // array of (key => value)
+
+ $keysByTableName = array();
+ foreach ( $keys as $key ) {
+ $tableName = $this->getTableByKey( $key );
+ if ( !isset( $keysByTableName[$tableName] ) ) {
+ $keysByTableName[$tableName] = array();
+ }
+ $keysByTableName[$tableName][] = $key;
}
- $this->debug( "get: retrieved data; expiry time is " . $row->exptime );
+ $db = $this->getDB();
+ $this->garbageCollect(); // expire old entries if any
- if ( $this->isExpired( $row->exptime ) ) {
- $this->debug( "get: key has expired, deleting" );
- try {
- $db->begin( __METHOD__ );
- # Put the expiry time in the WHERE condition to avoid deleting a
- # newly-inserted value
- $db->delete( $tableName,
- array(
- 'keyname' => $key,
- 'exptime' => $row->exptime
- ), __METHOD__ );
- $db->commit( __METHOD__ );
- } catch ( DBQueryError $e ) {
- $this->handleWriteError( $e );
+ $dataRows = array();
+ foreach ( $keysByTableName as $tableName => $tableKeys ) {
+ $res = $db->select( $tableName,
+ array( 'keyname', 'value', 'exptime' ),
+ array( 'keyname' => $tableKeys ),
+ __METHOD__ );
+ foreach ( $res as $row ) {
+ $dataRows[$row->keyname] = $row;
}
+ }
- return false;
+ foreach ( $keys as $key ) {
+ if ( isset( $dataRows[$key] ) ) { // HIT?
+ $row = $dataRows[$key];
+ $this->debug( "get: retrieved data; expiry time is " . $row->exptime );
+ if ( $this->isExpired( $row->exptime ) ) { // MISS
+ $this->debug( "get: key has expired, deleting" );
+ try {
+ $db->begin( __METHOD__ );
+ # Put the expiry time in the WHERE condition to avoid deleting a
+ # newly-inserted value
+ $db->delete( $this->getTableByKey( $key ),
+ array( 'keyname' => $key, 'exptime' => $row->exptime ),
+ __METHOD__ );
+ $db->commit( __METHOD__ );
+ } catch ( DBQueryError $e ) {
+ $this->handleWriteError( $e );
+ }
+ $values[$key] = false;
+ } else { // HIT
+ $values[$key] = $this->unserialize( $db->decodeBlob( $row->value ) );
+ }
+ } else { // MISS
+ $values[$key] = false;
+ $this->debug( 'get: no matching rows' );
+ }
}
- return $this->unserialize( $db->decodeBlob( $row->value ) );
+ return $values;
}
public function set( $key, $value, $exptime = 0 ) {
if ( $maxExpTime !== false ) {
$conds[] = 'exptime > ' . $db->addQuotes( $maxExpTime );
}
- $rows = $db->select(
+ $rows = $db->select(
$this->getTableByShard( $i ),
array( 'keyname', 'exptime' ),
$conds,
$db->begin( __METHOD__ );
$db->delete(
$this->getTableByShard( $i ),
- array(
+ array(
'exptime >= ' . $db->addQuotes( $minExpTime ),
'exptime < ' . $db->addQuotes( $dbTimestamp ),
'keyname' => $keys
if ( intval( $totalSeconds ) === 0 ) {
$percent = 0;
} else {
- $remainingSeconds = wfTimestamp( TS_UNIX, $timestamp )
+ $remainingSeconds = wfTimestamp( TS_UNIX, $timestamp )
- wfTimestamp( TS_UNIX, $maxExpTime );
if ( $remainingSeconds > $totalSeconds ) {
$totalSeconds = $remainingSeconds;
}
- $percent = ( $i + $remainingSeconds / $totalSeconds )
+ $percent = ( $i + $remainingSeconds / $totalSeconds )
/ $this->shards * 100;
}
call_user_func( $progressCallback, $percent );
quote-nbsp: yes
fix-backslash: no
fix-uri: no
+new-inline-tags: video,audio,source,track
* @ingroup Maintenance
*/
+require_once( dirname( __FILE__ ) . '/backup.inc' );
/**
* @ingroup Maintenance
$optionsWithArgs = array( 'pagelist', 'start', 'end', 'revstart', 'revend');
require_once( dirname( __FILE__ ) . '/commandLine.inc' );
-require_once( 'backup.inc' );
+require_once( dirname( __FILE__ ) . '/backup.inc' );
$dumper = new BackupDumper( $argv );
$originalDir = getcwd();
require_once( dirname( __FILE__ ) . '/commandLine.inc' );
-require_once( 'backup.inc' );
-require_once( 'backupTextPass.inc' );
+require_once( dirname( __FILE__ ) . '/backupTextPass.inc' );
$dumper = new TextPassDumper( $argv );