}
}
- /**
- * Fields in the image table
- * @deprecated since 1.31, use self::getQueryInfo() instead.
- * @return string[]
- */
- static function selectFields() {
- global $wgActorTableSchemaMigrationStage;
-
- wfDeprecated( __METHOD__, '1.31' );
- if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_READ_NEW ) {
- // If code is using this instead of self::getQueryInfo(), there's a
- // decent chance it's going to try to directly access
- // $row->img_user or $row->img_user_text and we can't give it
- // useful values here once those aren't being used anymore.
- throw new BadMethodCallException(
- 'Cannot use ' . __METHOD__
- . ' when $wgActorTableSchemaMigrationStage has SCHEMA_COMPAT_READ_NEW'
- );
- }
-
- return [
- 'img_name',
- 'img_size',
- 'img_width',
- 'img_height',
- 'img_metadata',
- 'img_bits',
- 'img_media_type',
- 'img_major_mime',
- 'img_minor_mime',
- 'img_user',
- 'img_user_text',
- 'img_actor' => 'NULL',
- 'img_timestamp',
- 'img_sha1',
- ] + MediaWikiServices::getInstance()->getCommentStore()->getFields( 'img_description' );
- }
-
/**
* Return the tables, fields, and join conditions to be selected to create
* a new localfile object.
$this->loadFromDB( self::READ_NORMAL );
$fields = $this->getCacheFields( '' );
+ $cacheVal = [];
$cacheVal['fileExists'] = $this->fileExists;
if ( $this->fileExists ) {
foreach ( $fields as $field ) {
/**
* Delete cached transformed files for the current version only.
* @param array $options
+ * @phan-param array{forThumbRefresh?:bool} $options
*/
public function purgeThumbnails( $options = [] ) {
$files = $this->getThumbnails();
$oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null, $tags = [],
$createNullRevision = true, $revert = false
) {
- global $wgActorTableSchemaMigrationStage;
-
if ( is_null( $user ) ) {
global $wgUser;
$user = $wgUser;
'oi_major_mime' => 'img_major_mime',
'oi_minor_mime' => 'img_minor_mime',
'oi_sha1' => 'img_sha1',
+ 'oi_actor' => 'img_actor',
];
$joins = [];
- if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) {
- $fields['oi_user'] = 'img_user';
- $fields['oi_user_text'] = 'img_user_text';
- }
- if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) {
- $fields['oi_actor'] = 'img_actor';
- }
-
- if (
- ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_BOTH ) === SCHEMA_COMPAT_WRITE_BOTH
- ) {
- // Upgrade any rows that are still old-style. Otherwise an upgrade
- // might be missed if a deletion happens while the migration script
- // is running.
- $res = $dbw->select(
- [ 'image' ],
- [ 'img_name', 'img_user', 'img_user_text' ],
- [ 'img_name' => $this->getName(), 'img_actor' => 0 ],
- __METHOD__
- );
- foreach ( $res as $row ) {
- $actorId = User::newFromAnyId( $row->img_user, $row->img_user_text, null )->getActorId( $dbw );
- $dbw->update(
- 'image',
- [ 'img_actor' => $actorId ],
- [ 'img_name' => $row->img_name, 'img_actor' => 0 ],
- __METHOD__
- );
- }
- }
-
# (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
# Add change tags, if any
if ( $tags ) {
- $logEntry->setTags( $tags );
+ $logEntry->addTags( $tags );
}
# Uploads can be patrolled
: FSFile::getSha1Base36FromPath( $srcPath );
/** @var FileBackendDBRepoWrapper $wrapperBackend */
$wrapperBackend = $repo->getBackend();
+ '@phan-var FileBackendDBRepoWrapper $wrapperBackend';
$dst = $wrapperBackend->getPathForSHA1( $sha1 );
$status = $repo->quickImport( $src, $dst );
if ( $flags & File::DELETE_SOURCE ) {
wfDebugLog( 'imagemove', "Finished moving {$this->name}" );
- // Purge the source and target files...
+ // Purge the source and target files outside the transaction...
$oldTitleFile = $localRepo->newFile( $this->title );
$newTitleFile = $localRepo->newFile( $target );
- // To avoid slow purges in the transaction, move them outside...
DeferredUpdates::addUpdate(
new AutoCommitUpdate(
$this->getRepo()->getMasterDB(),
function () use ( $oldTitleFile, $newTitleFile, $archiveNames ) {
$oldTitleFile->purgeEverything();
foreach ( $archiveNames as $archiveName ) {
+ /** @var OldLocalFile $oldTitleFile */
+ '@phan-var OldLocalFile $oldTitleFile';
$oldTitleFile->purgeOldThumbnails( $archiveName );
}
$newTitleFile->purgeEverything();
// Now switch the object
$this->title = $target;
// Force regeneration of the name and hashpath
- unset( $this->name );
- unset( $this->hashPath );
+ $this->name = null;
+ $this->hashPath = null;
}
return $status;