MediaWiki  REL1_24
RevDelFileList.php
Go to the documentation of this file.
00001 <?php
00025 class RevDelFileList extends RevDelList {
00027     public $storeBatch;
00028 
00030     public $deleteBatch;
00031 
00033     public $cleanupBatch;
00034 
00035     public function getType() {
00036         return 'oldimage';
00037     }
00038 
00039     public static function getRelationType() {
00040         return 'oi_archive_name';
00041     }
00042 
00043     public static function getRestriction() {
00044         return 'deleterevision';
00045     }
00046 
00047     public static function getRevdelConstant() {
00048         return File::DELETED_FILE;
00049     }
00050 
00055     public function doQuery( $db ) {
00056         $archiveNames = array();
00057         foreach ( $this->ids as $timestamp ) {
00058             $archiveNames[] = $timestamp . '!' . $this->title->getDBkey();
00059         }
00060 
00061         return $db->select(
00062             'oldimage',
00063             OldLocalFile::selectFields(),
00064             array(
00065                 'oi_name' => $this->title->getDBkey(),
00066                 'oi_archive_name' => $archiveNames
00067             ),
00068             __METHOD__,
00069             array( 'ORDER BY' => 'oi_timestamp DESC' )
00070         );
00071     }
00072 
00073     public function newItem( $row ) {
00074         return new RevDelFileItem( $this, $row );
00075     }
00076 
00077     public function clearFileOps() {
00078         $this->deleteBatch = array();
00079         $this->storeBatch = array();
00080         $this->cleanupBatch = array();
00081     }
00082 
00083     public function doPreCommitUpdates() {
00084         $status = Status::newGood();
00085         $repo = RepoGroup::singleton()->getLocalRepo();
00086         if ( $this->storeBatch ) {
00087             $status->merge( $repo->storeBatch( $this->storeBatch, FileRepo::OVERWRITE_SAME ) );
00088         }
00089         if ( !$status->isOK() ) {
00090             return $status;
00091         }
00092         if ( $this->deleteBatch ) {
00093             $status->merge( $repo->deleteBatch( $this->deleteBatch ) );
00094         }
00095         if ( !$status->isOK() ) {
00096             // Running cleanupDeletedBatch() after a failed storeBatch() with the DB already
00097             // modified (but destined for rollback) causes data loss
00098             return $status;
00099         }
00100         if ( $this->cleanupBatch ) {
00101             $status->merge( $repo->cleanupDeletedBatch( $this->cleanupBatch ) );
00102         }
00103 
00104         return $status;
00105     }
00106 
00107     public function doPostCommitUpdates() {
00108         $file = wfLocalFile( $this->title );
00109         $file->purgeCache();
00110         $file->purgeDescription();
00111         $purgeUrls = array();
00112         foreach ( $this->ids as $timestamp ) {
00113             $archiveName = $timestamp . '!' . $this->title->getDBkey();
00114             $file->purgeOldThumbnails( $archiveName );
00115             $purgeUrls[] = $file->getArchiveUrl( $archiveName );
00116         }
00117         if ( $this->getConfig()->get( 'UseSquid' ) ) {
00118             // purge full images from cache
00119             SquidUpdate::purge( $purgeUrls );
00120         }
00121 
00122         return Status::newGood();
00123     }
00124 
00125     public function getSuppressBit() {
00126         return File::DELETED_RESTRICTED;
00127     }
00128 }