MediaWiki  master
LocalFileMoveBatch Class Reference

Helper class for file movement. More...

Collaboration diagram for LocalFileMoveBatch:

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

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

Detailed Description

Helper class for file movement.

Definition at line 32 of file LocalFileMoveBatch.php.

Constructor & Destructor Documentation

◆ __construct()

LocalFileMoveBatch::__construct ( LocalFile  $file,
Title  $target 
)
Parameters
LocalFile$file
Title$target

Definition at line 84 of file LocalFileMoveBatch.php.

References $file, $newName, $oldName, $target, and LocalFile\getRepo().

Member Function Documentation

◆ acquireSourceLock()

LocalFileMoveBatch::acquireSourceLock ( )
protected

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

Returns
Status

Definition at line 172 of file LocalFileMoveBatch.php.

References StatusValue\newGood().

Referenced by addCurrent(), and execute().

◆ acquireTargetLock()

LocalFileMoveBatch::acquireTargetLock ( )
protected

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

Returns
Status

Definition at line 188 of file LocalFileMoveBatch.php.

References getTargetFile(), and StatusValue\newGood().

Referenced by execute().

◆ addCurrent()

LocalFileMoveBatch::addCurrent ( )

Add the current image to the batch.

Returns
Status

Definition at line 103 of file LocalFileMoveBatch.php.

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

◆ addOlds()

LocalFileMoveBatch::addOlds ( )

Add the old versions of the image to the batch.

Returns
string[] List of archive names from old versions

Definition at line 115 of file LocalFileMoveBatch.php.

References $oldName, and File\DELETED_FILE.

◆ cleanupSource()

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 471 of file LocalFileMoveBatch.php.

Referenced by execute().

◆ cleanupTarget()

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 455 of file LocalFileMoveBatch.php.

Referenced by execute().

◆ doDBUpdates()

LocalFileMoveBatch::doDBUpdates ( )
protected

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

Definition at line 367 of file LocalFileMoveBatch.php.

References $db, and Wikimedia\Rdbms\IDatabase\update().

Referenced by execute().

◆ execute()

◆ getMoveTriplets()

LocalFileMoveBatch::getMoveTriplets ( )
protected

Generate triplets for FileRepo::storeBatch().

Returns
array[]

Definition at line 395 of file LocalFileMoveBatch.php.

Referenced by execute().

◆ getTargetFile()

LocalFileMoveBatch::getTargetFile ( )
protected

Get the target file.

Returns
LocalFile

Definition at line 218 of file LocalFileMoveBatch.php.

Referenced by acquireTargetLock(), and releaseLocks().

◆ releaseLocks()

LocalFileMoveBatch::releaseLocks ( )
protected

Release both file locks.

Definition at line 202 of file LocalFileMoveBatch.php.

References getTargetFile().

Referenced by execute().

◆ removeNonexistentFiles()

LocalFileMoveBatch::removeNonexistentFiles (   $triplets)
protected

Removes non-existent files from move batch.

Parameters
array[]$triplets
Returns
Status

Definition at line 422 of file LocalFileMoveBatch.php.

References $file, StatusValue\newFatal(), and StatusValue\newGood().

Referenced by execute().

◆ verifyDBUpdates()

LocalFileMoveBatch::verifyDBUpdates ( )
protected

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

Returns
Status

Definition at line 330 of file LocalFileMoveBatch.php.

References $db, and Wikimedia\Rdbms\IDatabase\lockForUpdate().

Referenced by execute().

Member Data Documentation

◆ $archive

LocalFileMoveBatch::$archive
protected

Definition at line 45 of file LocalFileMoveBatch.php.

◆ $cur

LocalFileMoveBatch::$cur
protected

Definition at line 39 of file LocalFileMoveBatch.php.

◆ $db

IDatabase LocalFileMoveBatch::$db
protected

Definition at line 48 of file LocalFileMoveBatch.php.

Referenced by doDBUpdates(), and verifyDBUpdates().

◆ $file

LocalFile LocalFileMoveBatch::$file
protected

Definition at line 34 of file LocalFileMoveBatch.php.

Referenced by __construct(), and removeNonexistentFiles().

◆ $newHash

string LocalFileMoveBatch::$newHash
protected

Definition at line 54 of file LocalFileMoveBatch.php.

◆ $newName

string LocalFileMoveBatch::$newName
protected

Definition at line 60 of file LocalFileMoveBatch.php.

Referenced by __construct().

◆ $newRel

string LocalFileMoveBatch::$newRel
protected

Definition at line 66 of file LocalFileMoveBatch.php.

Referenced by addCurrent().

◆ $oldCount

LocalFileMoveBatch::$oldCount
protected

Definition at line 43 of file LocalFileMoveBatch.php.

◆ $oldHash

string LocalFileMoveBatch::$oldHash
protected

Definition at line 51 of file LocalFileMoveBatch.php.

◆ $oldName

string LocalFileMoveBatch::$oldName
protected

Definition at line 57 of file LocalFileMoveBatch.php.

Referenced by __construct(), and addOlds().

◆ $oldRel

string LocalFileMoveBatch::$oldRel
protected

Definition at line 63 of file LocalFileMoveBatch.php.

Referenced by addCurrent().

◆ $olds

LocalFileMoveBatch::$olds
protected

Definition at line 41 of file LocalFileMoveBatch.php.

◆ $target

Title LocalFileMoveBatch::$target
protected

Definition at line 37 of file LocalFileMoveBatch.php.

Referenced by __construct().


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