MediaWiki master
MediaWiki\FileRepo\File\LocalFileMoveBatch Class Reference

Helper class for file movement. More...

Collaboration diagram for MediaWiki\FileRepo\File\LocalFileMoveBatch:

Public Member Functions

 __construct (LocalFile $file, Title $target)
 addCurrent ()
 Add the current image to the batch.
 addOlds ()
 Add the old versions of the image to the batch.
 execute ()
 Perform the move.

Protected Member Functions

 acquireSourceLock ()
 Acquire the source file lock, if it has not been acquired already.
 acquireTargetLock ()
 Acquire the target file lock, if it has not been acquired already.
 cleanupSource ( $triplets)
 Cleanup a fully moved array of triplets by deleting the source files.
 cleanupTarget ( $triplets)
 Cleanup a partially moved array of triplets by deleting the target files.
 doDBUpdates ()
 Do the database updates and return a new Status indicating how many rows where updated.
 getMoveTriplets ()
 Generate triplets for FileRepo::storeBatch().
 getTargetFile ()
 Get the target file.
 releaseLocks ()
 Release both file locks.
 removeNonexistentFiles ( $triplets)
 Removes non-existent files from move batch.
 verifyDBUpdates ()
 Verify the database updates and return a new Status indicating how many rows would be updated.

Protected Attributes

string[] $cur
IDatabase $db
LocalFile $file
string $newHash
string $newName
string $newRel
int $oldCount
string $oldHash
string $oldName
string $oldRel
string[][] $olds
Title $target

Detailed Description

Helper class for file movement.

Definition at line 25 of file LocalFileMoveBatch.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\FileRepo\File\LocalFileMoveBatch::__construct ( LocalFile $file,
Title $target )

Member Function Documentation

◆ acquireSourceLock()

MediaWiki\FileRepo\File\LocalFileMoveBatch::acquireSourceLock ( )
protected

Acquire the source file lock, if it has not been acquired already.

Returns
Status

Definition at line 178 of file LocalFileMoveBatch.php.

Referenced by addCurrent(), and execute().

◆ acquireTargetLock()

MediaWiki\FileRepo\File\LocalFileMoveBatch::acquireTargetLock ( )
protected

Acquire the target file lock, if it has not been acquired already.

Returns
Status

Definition at line 194 of file LocalFileMoveBatch.php.

References getTargetFile().

Referenced by execute().

◆ addCurrent()

MediaWiki\FileRepo\File\LocalFileMoveBatch::addCurrent ( )

Add the current image to the batch.

Returns
Status

Definition at line 93 of file LocalFileMoveBatch.php.

References $newRel, $oldRel, and acquireSourceLock().

◆ addOlds()

MediaWiki\FileRepo\File\LocalFileMoveBatch::addOlds ( )

Add the old versions of the image to the batch.

Returns
string[] List of archive names from old versions

Definition at line 105 of file LocalFileMoveBatch.php.

References $oldName, MediaWiki\FileRepo\File\File\DELETED_FILE, MediaWiki\MainConfigNames\FileSchemaMigrationStage, MediaWiki\MediaWikiServices\getInstance(), and SCHEMA_COMPAT_WRITE_OLD.

◆ cleanupSource()

MediaWiki\FileRepo\File\LocalFileMoveBatch::cleanupSource ( $triplets)
protected

Cleanup a fully moved array of triplets by deleting the source files.

Called at the end of the move process if everything else went ok.

Parameters
array[]$triplets

Definition at line 539 of file LocalFileMoveBatch.php.

Referenced by execute().

◆ cleanupTarget()

MediaWiki\FileRepo\File\LocalFileMoveBatch::cleanupTarget ( $triplets)
protected

Cleanup a partially moved array of triplets by deleting the target files.

Called if something went wrong half way.

Parameters
array[]$triplets

Definition at line 523 of file LocalFileMoveBatch.php.

Referenced by execute().

◆ doDBUpdates()

MediaWiki\FileRepo\File\LocalFileMoveBatch::doDBUpdates ( )
protected

Do the database updates and return a new Status indicating how many rows where updated.

Definition at line 387 of file LocalFileMoveBatch.php.

References $db, MediaWiki\MainConfigNames\FileSchemaMigrationStage, MediaWiki\MediaWikiServices\getInstance(), SCHEMA_COMPAT_WRITE_NEW, and SCHEMA_COMPAT_WRITE_OLD.

Referenced by execute().

◆ execute()

MediaWiki\FileRepo\File\LocalFileMoveBatch::execute ( )

◆ getMoveTriplets()

MediaWiki\FileRepo\File\LocalFileMoveBatch::getMoveTriplets ( )
protected

Generate triplets for FileRepo::storeBatch().

Returns
array[]

Definition at line 464 of file LocalFileMoveBatch.php.

Referenced by execute().

◆ getTargetFile()

MediaWiki\FileRepo\File\LocalFileMoveBatch::getTargetFile ( )
protected

Get the target file.

Returns
LocalFile

Definition at line 224 of file LocalFileMoveBatch.php.

References MediaWiki\MediaWikiServices\getInstance().

Referenced by acquireTargetLock(), and releaseLocks().

◆ releaseLocks()

MediaWiki\FileRepo\File\LocalFileMoveBatch::releaseLocks ( )
protected

Release both file locks.

Definition at line 208 of file LocalFileMoveBatch.php.

References getTargetFile().

Referenced by execute().

◆ removeNonexistentFiles()

MediaWiki\FileRepo\File\LocalFileMoveBatch::removeNonexistentFiles ( $triplets)
protected

Removes non-existent files from move batch.

Parameters
array[]$triplets
Returns
Status

Definition at line 490 of file LocalFileMoveBatch.php.

References $file.

Referenced by execute().

◆ verifyDBUpdates()

MediaWiki\FileRepo\File\LocalFileMoveBatch::verifyDBUpdates ( )
protected

Verify the database updates and return a new Status indicating how many rows would be updated.

Returns
Status

Definition at line 334 of file LocalFileMoveBatch.php.

References $db, MediaWiki\MainConfigNames\FileSchemaMigrationStage, MediaWiki\MediaWikiServices\getInstance(), and SCHEMA_COMPAT_WRITE_OLD.

Referenced by execute().

Member Data Documentation

◆ $cur

string [] MediaWiki\FileRepo\File\LocalFileMoveBatch::$cur
protected

Definition at line 33 of file LocalFileMoveBatch.php.

◆ $db

IDatabase MediaWiki\FileRepo\File\LocalFileMoveBatch::$db
protected

Definition at line 42 of file LocalFileMoveBatch.php.

Referenced by doDBUpdates(), and verifyDBUpdates().

◆ $file

LocalFile MediaWiki\FileRepo\File\LocalFileMoveBatch::$file
protected

Definition at line 27 of file LocalFileMoveBatch.php.

Referenced by __construct(), and removeNonexistentFiles().

◆ $newHash

string MediaWiki\FileRepo\File\LocalFileMoveBatch::$newHash
protected

Definition at line 48 of file LocalFileMoveBatch.php.

◆ $newName

string MediaWiki\FileRepo\File\LocalFileMoveBatch::$newName
protected

Definition at line 54 of file LocalFileMoveBatch.php.

Referenced by __construct().

◆ $newRel

string MediaWiki\FileRepo\File\LocalFileMoveBatch::$newRel
protected

Definition at line 60 of file LocalFileMoveBatch.php.

Referenced by addCurrent().

◆ $oldCount

int MediaWiki\FileRepo\File\LocalFileMoveBatch::$oldCount
protected

Definition at line 39 of file LocalFileMoveBatch.php.

◆ $oldHash

string MediaWiki\FileRepo\File\LocalFileMoveBatch::$oldHash
protected

Definition at line 45 of file LocalFileMoveBatch.php.

◆ $oldName

string MediaWiki\FileRepo\File\LocalFileMoveBatch::$oldName
protected

Definition at line 51 of file LocalFileMoveBatch.php.

Referenced by __construct(), and addOlds().

◆ $oldRel

string MediaWiki\FileRepo\File\LocalFileMoveBatch::$oldRel
protected

Definition at line 57 of file LocalFileMoveBatch.php.

Referenced by addCurrent().

◆ $olds

string [][] MediaWiki\FileRepo\File\LocalFileMoveBatch::$olds
protected

Definition at line 36 of file LocalFileMoveBatch.php.

◆ $target

Title MediaWiki\FileRepo\File\LocalFileMoveBatch::$target
protected

Definition at line 30 of file LocalFileMoveBatch.php.

Referenced by __construct().


The documentation for this class was generated from the following file: