MediaWiki  master
RevDelFileList.php
Go to the documentation of this file.
1 <?php
25 
29 class RevDelFileList extends RevDelList {
30 
33 
35  private $repoGroup;
36 
38  public $storeBatch;
39 
41  public $deleteBatch;
42 
44  public $cleanupBatch;
45 
54  public function __construct(
57  array $ids,
61  ) {
62  parent::__construct( $context, $page, $ids, $lbFactory );
63  $this->htmlCacheUpdater = $htmlCacheUpdater;
64  $this->repoGroup = $repoGroup;
65  }
66 
67  public function getType() {
68  return 'oldimage';
69  }
70 
71  public static function getRelationType() {
72  return 'oi_archive_name';
73  }
74 
75  public static function getRestriction() {
76  return 'deleterevision';
77  }
78 
79  public static function getRevdelConstant() {
80  return File::DELETED_FILE;
81  }
82 
87  public function doQuery( $db ) {
88  $archiveNames = [];
89  foreach ( $this->ids as $timestamp ) {
90  $archiveNames[] = $timestamp . '!' . $this->page->getDBkey();
91  }
92 
93  $oiQuery = OldLocalFile::getQueryInfo();
94  return $db->select(
95  $oiQuery['tables'],
96  $oiQuery['fields'],
97  [
98  'oi_name' => $this->page->getDBkey(),
99  'oi_archive_name' => $archiveNames
100  ],
101  __METHOD__,
102  [ 'ORDER BY' => 'oi_timestamp DESC' ],
103  $oiQuery['joins']
104  );
105  }
106 
107  public function newItem( $row ) {
108  return new RevDelFileItem( $this, $row );
109  }
110 
111  public function clearFileOps() {
112  $this->deleteBatch = [];
113  $this->storeBatch = [];
114  $this->cleanupBatch = [];
115  }
116 
117  public function doPreCommitUpdates() {
118  $status = Status::newGood();
119  $repo = $this->repoGroup->getLocalRepo();
120  if ( $this->storeBatch ) {
121  $status->merge( $repo->storeBatch( $this->storeBatch, FileRepo::OVERWRITE_SAME ) );
122  }
123  if ( !$status->isOK() ) {
124  return $status;
125  }
126  if ( $this->deleteBatch ) {
127  $status->merge( $repo->deleteBatch( $this->deleteBatch ) );
128  }
129  if ( !$status->isOK() ) {
130  // Running cleanupDeletedBatch() after a failed storeBatch() with the DB already
131  // modified (but destined for rollback) causes data loss
132  return $status;
133  }
134  if ( $this->cleanupBatch ) {
135  $status->merge( $repo->cleanupDeletedBatch( $this->cleanupBatch ) );
136  }
137 
138  return $status;
139  }
140 
141  public function doPostCommitUpdates( array $visibilityChangeMap ) {
142  $file = $this->repoGroup->getLocalRepo()->newFile( $this->page );
143  $file->purgeCache();
144  $file->purgeDescription();
145 
146  // Purge full images from cache
147  $purgeUrls = [];
148  foreach ( $this->ids as $timestamp ) {
149  $archiveName = $timestamp . '!' . $this->page->getDBkey();
150  $file->purgeOldThumbnails( $archiveName );
151  $purgeUrls[] = $file->getArchiveUrl( $archiveName );
152  }
153 
154  $this->htmlCacheUpdater->purgeUrls(
155  $purgeUrls,
156  HtmlCacheUpdater::PURGE_INTENT_TXROUND_REFLECTED
157  );
158 
159  return Status::newGood();
160  }
161 
162  public function getSuppressBit() {
164  }
165 }
IContextSource $context
const OVERWRITE_SAME
Definition: FileRepo.php:50
const DELETED_RESTRICTED
Definition: File.php:75
const DELETED_FILE
Definition: File.php:72
Class to invalidate the CDN and HTMLFileCache entries associated with URLs/titles.
static getQueryInfo(array $options=[])
Return the tables, fields, and join conditions to be selected to create a new oldlocalfile object.
Prioritized list of file repositories.
Definition: RepoGroup.php:29
Item class for an oldimage table row.
List for oldimage table items.
getSuppressBit()
Get the integer value of the flag used for suppression.
__construct(IContextSource $context, PageIdentity $page, array $ids, LBFactory $lbFactory, HtmlCacheUpdater $htmlCacheUpdater, RepoGroup $repoGroup)
static getRelationType()
Get the DB field name associated with the ID list.
doPostCommitUpdates(array $visibilityChangeMap)
A hook for setVisibility(): do any necessary updates post-commit.
HtmlCacheUpdater $htmlCacheUpdater
doPreCommitUpdates()
A hook for setVisibility(): do batch updates pre-commit.
clearFileOps()
Clear any data structures needed for doPreCommitUpdates() and doPostCommitUpdates() STUB.
newItem( $row)
Create an item object from a DB result row.
getType()
Get the internal type name of this list.
static getRevdelConstant()
Get the revision deletion constant for this list type Override this function.
static getRestriction()
Get the user right required for this list type Override this function.
RepoGroup $repoGroup
LBFactory $lbFactory
Definition: RevDelList.php:40
PageIdentity $page
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:82
An interface for generating database load balancers.
Definition: LBFactory.php:43
Interface for objects which can provide a MediaWiki context on request.
Interface for objects (potentially) representing an editable wiki page.
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:39
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition: router.php:42