*/
use \MediaWiki\Logger\LoggerFactory;
+use Wikimedia\Rdbms\IDatabase;
/**
* Class to represent a local file in the wiki's own database
return $this->repo->getSharedCacheKey( 'file', sha1( $this->getName() ) );
}
+ /**
+ * @param WANObjectCache $cache
+ * @return string[]
+ * @since 1.28
+ */
+ public function getMutableCacheKeys( WANObjectCache $cache ) {
+ return [ $this->getCacheKey() ];
+ }
+
/**
* Try to load file metadata from memcached, falling back to the database
*/
* @param int $flags
*/
function loadFromDB( $flags = 0 ) {
- $fname = get_class( $this ) . '::' . __FUNCTION__;
+ $fname = static::class . '::' . __FUNCTION__;
# Unconditionally set loaded=true, we don't want the accessors constantly rechecking
$this->dataLoaded = true;
* This covers fields that are sometimes not cached.
*/
protected function loadExtraFromDB() {
- $fname = get_class( $this ) . '::' . __FUNCTION__;
+ $fname = static::class . '::' . __FUNCTION__;
# Unconditionally set loaded=true, we don't want the accessors constantly rechecking
$this->extraDataLoaded = true;
$files[] = $file;
}
} catch ( FileBackendError $e ) {
- } // suppress (bug 54674)
+ } // suppress (T56674)
return $files;
}
$opts['ORDER BY'] = "oi_timestamp $order";
$opts['USE INDEX'] = [ 'oldimage' => 'oi_name_timestamp' ];
- Hooks::run( 'LocalFile::getHistory', [ &$this, &$tables, &$fields,
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $localFile = $this;
+ Hooks::run( 'LocalFile::getHistory', [ &$localFile, &$tables, &$fields,
&$conds, &$opts, &$join_conds ] );
$res = $dbr->select( $tables, $fields, $conds, __METHOD__, $opts, $join_conds );
*/
public function nextHistoryLine() {
# Polymorphic function name to distinguish foreign and local fetches
- $fname = get_class( $this ) . '::' . __FUNCTION__;
+ $fname = static::class . '::' . __FUNCTION__;
$dbr = $this->repo->getReplicaDB();
}
}
- # (bug 34993) Note: $oldver can be empty here, if the previous
+ # (T36993) Note: $oldver can be empty here, if the previous
# version of the file was broken. Allow registration of the new
# version to continue anyway, because that's better than having
# an image that's not fixable by user operations.
$dbw = $this->repo->getMasterDB();
$makesTransaction = !$dbw->trxLevel();
$dbw->startAtomic( self::ATOMIC_SECTION_LOCK );
- // Bug 54736: use simple lock to handle when the file does not exist.
+ // T56736: use simple lock to handle when the file does not exist.
// SELECT FOR UPDATE prevents changes, not other SELECTs with FOR UPDATE.
// Also, that would cause contention on INSERT of similarly named rows.
$status = $this->acquireFileLock(); // represents all versions of the file
$status->failCount++;
}
$status->successCount += $oldRowCount;
- // Bug 34934: oldCount is based on files that actually exist.
+ // T36934: oldCount is based on files that actually exist.
// There may be more DB rows than such files, in which case $affected
// can be greater than $total. We use max() to avoid negatives here.
$status->failCount += max( 0, $this->oldCount - $oldRowCount );