MediaWiki  master
RevDelFileList.php
Go to the documentation of this file.
1 <?php
24 
28 class RevDelFileList extends RevDelList {
30  public $storeBatch;
31 
33  public $deleteBatch;
34 
36  public $cleanupBatch;
37 
38  public function getType() {
39  return 'oldimage';
40  }
41 
42  public static function getRelationType() {
43  return 'oi_archive_name';
44  }
45 
46  public static function getRestriction() {
47  return 'deleterevision';
48  }
49 
50  public static function getRevdelConstant() {
51  return File::DELETED_FILE;
52  }
53 
58  public function doQuery( $db ) {
59  $archiveNames = [];
60  foreach ( $this->ids as $timestamp ) {
61  $archiveNames[] = $timestamp . '!' . $this->title->getDBkey();
62  }
63 
64  $oiQuery = OldLocalFile::getQueryInfo();
65  return $db->select(
66  $oiQuery['tables'],
67  $oiQuery['fields'],
68  [
69  'oi_name' => $this->title->getDBkey(),
70  'oi_archive_name' => $archiveNames
71  ],
72  __METHOD__,
73  [ 'ORDER BY' => 'oi_timestamp DESC' ],
74  $oiQuery['joins']
75  );
76  }
77 
78  public function newItem( $row ) {
79  return new RevDelFileItem( $this, $row );
80  }
81 
82  public function clearFileOps() {
83  $this->deleteBatch = [];
84  $this->storeBatch = [];
85  $this->cleanupBatch = [];
86  }
87 
88  public function doPreCommitUpdates() {
89  $status = Status::newGood();
90  $repo = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo();
91  if ( $this->storeBatch ) {
92  $status->merge( $repo->storeBatch( $this->storeBatch, FileRepo::OVERWRITE_SAME ) );
93  }
94  if ( !$status->isOK() ) {
95  return $status;
96  }
97  if ( $this->deleteBatch ) {
98  $status->merge( $repo->deleteBatch( $this->deleteBatch ) );
99  }
100  if ( !$status->isOK() ) {
101  // Running cleanupDeletedBatch() after a failed storeBatch() with the DB already
102  // modified (but destined for rollback) causes data loss
103  return $status;
104  }
105  if ( $this->cleanupBatch ) {
106  $status->merge( $repo->cleanupDeletedBatch( $this->cleanupBatch ) );
107  }
108 
109  return $status;
110  }
111 
112  public function doPostCommitUpdates( array $visibilityChangeMap ) {
113  $file = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
114  ->newFile( $this->title );
115  $file->purgeCache();
116  $file->purgeDescription();
117 
118  // Purge full images from cache
119  $purgeUrls = [];
120  foreach ( $this->ids as $timestamp ) {
121  $archiveName = $timestamp . '!' . $this->title->getDBkey();
122  $file->purgeOldThumbnails( $archiveName );
123  $purgeUrls[] = $file->getArchiveUrl( $archiveName );
124  }
125 
126  $hcu = MediaWikiServices::getInstance()->getHtmlCacheUpdater();
127  $hcu->purgeUrls( $purgeUrls, $hcu::PURGE_INTENT_TXROUND_REFLECTED );
128 
129  return Status::newGood();
130  }
131 
132  public function getSuppressBit() {
134  }
135 }
FileRepo\OVERWRITE_SAME
const OVERWRITE_SAME
Definition: FileRepo.php:44
File\DELETED_RESTRICTED
const DELETED_RESTRICTED
Definition: File.php:69
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:149
OldLocalFile\getQueryInfo
static getQueryInfo(array $options=[])
Return the tables, fields, and join conditions to be selected to create a new oldlocalfile object.
Definition: OldLocalFile.php:120
$file
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition: router.php:42
RevDelFileList\newItem
newItem( $row)
Create an item object from a DB result row.
Definition: RevDelFileList.php:78
RevDelFileList\clearFileOps
clearFileOps()
Clear any data structures needed for doPreCommitUpdates() and doPostCommitUpdates() STUB.
Definition: RevDelFileList.php:82
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
RevDelFileList\getRestriction
static getRestriction()
Get the user right required for this list type Override this function.
Definition: RevDelFileList.php:46
RevDelList
Definition: RevDelList.php:36
RevDelFileList\getRevdelConstant
static getRevdelConstant()
Get the revision deletion constant for this list type Override this function.
Definition: RevDelFileList.php:50
RevDelFileList\doPreCommitUpdates
doPreCommitUpdates()
A hook for setVisibility(): do batch updates pre-commit.
Definition: RevDelFileList.php:88
RevDelFileList\getRelationType
static getRelationType()
Get the DB field name associated with the ID list.
Definition: RevDelFileList.php:42
RevDelFileList\doPostCommitUpdates
doPostCommitUpdates(array $visibilityChangeMap)
A hook for setVisibility(): do any necessary updates post-commit.
Definition: RevDelFileList.php:112
StatusValue\newGood
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:81
RevDelFileItem
Item class for an oldimage table row.
Definition: RevDelFileItem.php:28
RevDelFileList\getType
getType()
Get the internal type name of this list.
Definition: RevDelFileList.php:38
RevDelFileList\$deleteBatch
array $deleteBatch
Definition: RevDelFileList.php:33
RevDelFileList\getSuppressBit
getSuppressBit()
Get the integer value of the flag used for suppression.
Definition: RevDelFileList.php:132
RevDelFileList
List for oldimage table items.
Definition: RevDelFileList.php:28
File\DELETED_FILE
const DELETED_FILE
Definition: File.php:66
RevDelFileList\doQuery
doQuery( $db)
Definition: RevDelFileList.php:58
RevDelFileList\$storeBatch
array $storeBatch
Definition: RevDelFileList.php:30
RevDelFileList\$cleanupBatch
array $cleanupBatch
Definition: RevDelFileList.php:36