*/
use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
/**
* A foreign repository with a remote MediaWiki with an API thingy
* @return bool|string
*/
function getThumbUrlFromCache( $name, $width, $height, $params = "" ) {
- $cache = ObjectCache::getMainWANInstance();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
// We can't check the local cache using FileRepo functions because
// we override fileExistsBatch(). We have to use the FileBackend directly.
$backend = $this->getBackend(); // convenience
$url = $this->makeUrl( $query, 'api' );
}
- $cache = ObjectCache::getMainWANInstance();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
return $cache->getWithSetCallback(
$this->getLocalCacheKey( static::class, $target, md5( $url ) ),
$cacheTTL,
* @ingroup FileRepo
*/
+use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\ResultWrapper;
use Wikimedia\Rdbms\Database;
use Wikimedia\Rdbms\IDatabase;
}
$method = __METHOD__;
- $redirDbKey = ObjectCache::getMainWANInstance()->getWithSetCallback(
+ $redirDbKey = MediaWikiServices::getInstance()->getMainWANObjectCache()->getWithSetCallback(
$memcKey,
$expiry,
function ( $oldValue, &$ttl, array &$setOpts ) use ( $method, $title ) {
if ( $key ) {
$this->getMasterDB()->onTransactionPreCommitOrIdle(
function () use ( $key ) {
- ObjectCache::getMainWANInstance()->delete( $key );
+ MediaWikiServices::getInstance()->getMainWANObjectCache()->delete( $key );
},
__METHOD__
);
* @ingroup FileAbstraction
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Class representing a row of the 'filearchive' table
*
'fa_deleted',
'fa_deleted_timestamp', /* Used by LocalFileRestoreBatch */
'fa_sha1',
- ] + CommentStore::getStore()->getFields( 'fa_description' );
+ ] + MediaWikiServices::getInstance()->getCommentStore()->getFields( 'fa_description' );
}
/**
* - joins: (array) to include in the `$join_conds` to `IDatabase->select()`
*/
public static function getQueryInfo() {
- $commentQuery = CommentStore::getStore()->getJoin( 'fa_description' );
+ $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'fa_description' );
$actorQuery = ActorMigration::newMigration()->getJoin( 'fa_user' );
return [
'tables' => [ 'filearchive' ] + $commentQuery['tables'] + $actorQuery['tables'],
$this->metadata = $row->fa_metadata;
$this->mime = "$row->fa_major_mime/$row->fa_minor_mime";
$this->media_type = $row->fa_media_type;
- $this->description = CommentStore::getStore()
+ $this->description = MediaWikiServices::getInstance()->getCommentStore()
// Legacy because $row may have come from self::selectFields()
->getCommentLegacy( wfGetDB( DB_REPLICA ), 'fa_description', $row )->text;
$this->user = User::newFromAnyId( $row->fa_user, $row->fa_user_text, $row->fa_actor );
$renderUrl = $this->repo->getDescriptionRenderUrl( $this->getName(), $lang->getCode() );
if ( $renderUrl ) {
- $cache = ObjectCache::getMainWANInstance();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
$key = $this->repo->getLocalCacheKey(
'RemoteFileDescription',
'url',
* @ingroup FileAbstraction
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Foreign file accessible through api.php requests.
* Very hacky and inefficient, do not use :D
$url = $this->repo->getDescriptionRenderUrl( $this->getName(), $wgContLang->getCode() );
$key = $this->repo->getLocalCacheKey( 'RemoteFileDescription', 'url', md5( $url ) );
- ObjectCache::getMainWANInstance()->delete( $key );
+ MediaWikiServices::getInstance()->getMainWANObjectCache()->delete( $key );
}
/**
*/
function purgeThumbnails( $options = [] ) {
$key = $this->repo->getLocalCacheKey( 'ForeignAPIRepo', 'ThumbUrl', $this->getName() );
- ObjectCache::getMainWANInstance()->delete( $key );
+ MediaWikiServices::getInstance()->getMainWANObjectCache()->delete( $key );
$files = $this->getThumbnails();
// Give media handler a chance to filter the purge list
* @ingroup FileAbstraction
*/
+use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\DBUnexpectedError;
/**
return false; // no description page
}
- $cache = ObjectCache::getMainWANInstance();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
return $cache->getWithSetCallback(
$this->repo->getLocalCacheKey(
'img_actor' => $wgActorTableSchemaMigrationStage > MIGRATION_OLD ? 'img_actor' : null,
'img_timestamp',
'img_sha1',
- ] + CommentStore::getStore()->getFields( 'img_description' );
+ ] + MediaWikiServices::getInstance()->getCommentStore()->getFields( 'img_description' );
}
/**
* - joins: (array) to include in the `$join_conds` to `IDatabase->select()`
*/
public static function getQueryInfo( array $options = [] ) {
- $commentQuery = CommentStore::getStore()->getJoin( 'img_description' );
+ $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'img_description' );
$actorQuery = ActorMigration::newMigration()->getJoin( 'img_user' );
$ret = [
'tables' => [ 'image' ] + $commentQuery['tables'] + $actorQuery['tables'],
return;
}
- $cache = ObjectCache::getMainWANInstance();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
$cachedValues = $cache->getWithSetCallback(
$key,
$cache::TTL_WEEK,
$this->repo->getMasterDB()->onTransactionPreCommitOrIdle(
function () use ( $key ) {
- ObjectCache::getMainWANInstance()->delete( $key );
+ MediaWikiServices::getInstance()->getMainWANObjectCache()->delete( $key );
},
__METHOD__
);
function decodeRow( $row, $prefix = 'img_' ) {
$decoded = $this->unprefixRow( $row, $prefix );
- $decoded['description'] = CommentStore::getStore()
+ $decoded['description'] = MediaWikiServices::getInstance()->getCommentStore()
->getComment( 'description', (object)$decoded )->text;
$decoded['user'] = User::newFromAnyId(
) {
$props = $this->repo->getFileProps( $srcPath );
} else {
- $mwProps = new MWFileProps( MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer() );
+ $mwProps = new MWFileProps( MediaWikiServices::getInstance()->getMimeAnalyzer() );
$props = $mwProps->getPropsFromPath( $srcPath, true );
}
}
# Test to see if the row exists using INSERT IGNORE
# This avoids race conditions by locking the row until the commit, and also
# doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition.
- $commentStore = CommentStore::getStore();
+ $commentStore = MediaWikiServices::getInstance()->getCommentStore();
list( $commentFields, $commentCallback ) =
$commentStore->insertWithTempTable( $dbw, 'img_description', $comment );
$actorMigration = ActorMigration::newMigration();
$now = time();
$dbw = $this->file->repo->getMasterDB();
- $commentStore = CommentStore::getStore();
+ $commentStore = MediaWikiServices::getInstance()->getCommentStore();
$actorMigration = ActorMigration::newMigration();
$encTimestamp = $dbw->addQuotes( $dbw->timestamp( $now ) );
$dbw = $this->file->repo->getMasterDB();
- $commentStore = CommentStore::getStore();
+ $commentStore = MediaWikiServices::getInstance()->getCommentStore();
$actorMigration = ActorMigration::newMigration();
$status = $this->file->repo->newGood();
* @ingroup FileAbstraction
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Class to represent a file in the oldimage table
*
'oi_timestamp',
'oi_deleted',
'oi_sha1',
- ] + CommentStore::getStore()->getFields( 'oi_description' );
+ ] + MediaWikiServices::getInstance()->getCommentStore()->getFields( 'oi_description' );
}
/**
* - joins: (array) to include in the `$join_conds` to `IDatabase->select()`
*/
public static function getQueryInfo( array $options = [] ) {
- $commentQuery = CommentStore::getStore()->getJoin( 'oi_description' );
+ $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'oi_description' );
$actorQuery = ActorMigration::newMigration()->getJoin( 'oi_user' );
$ret = [
'tables' => [ 'oldimage' ] + $commentQuery['tables'] + $actorQuery['tables'],
return false;
}
- $commentFields = CommentStore::getStore()->insert( $dbw, 'oi_description', $comment );
+ $commentFields = MediaWikiServices::getInstance()->getCommentStore()
+ ->insert( $dbw, 'oi_description', $comment );
$actorFields = ActorMigration::newMigration()->getInsertValues( $dbw, 'oi_user', $user );
$dbw->insert( 'oldimage',
[