MediaWiki  master
RevDelFileList.php
Go to the documentation of this file.
1 <?php
26 
30 class RevDelFileList extends RevDelList {
31 
33  private $htmlCacheUpdater;
34 
36  private $repoGroup;
37 
39  public $storeBatch;
40 
42  public $deleteBatch;
43 
45  public $cleanupBatch;
46 
55  public function __construct(
56  IContextSource $context,
58  array $ids,
59  LBFactory $lbFactory,
60  HtmlCacheUpdater $htmlCacheUpdater,
61  RepoGroup $repoGroup
62  ) {
63  parent::__construct( $context, $page, $ids, $lbFactory );
64  $this->htmlCacheUpdater = $htmlCacheUpdater;
65  $this->repoGroup = $repoGroup;
66  }
67 
68  public function getType() {
69  return 'oldimage';
70  }
71 
72  public static function getRelationType() {
73  return 'oi_archive_name';
74  }
75 
76  public static function getRestriction() {
77  return 'deleterevision';
78  }
79 
80  public static function getRevdelConstant() {
81  return File::DELETED_FILE;
82  }
83 
88  public function doQuery( $db ) {
89  $archiveNames = [];
90  foreach ( $this->ids as $timestamp ) {
91  $archiveNames[] = $timestamp . '!' . $this->page->getDBkey();
92  }
93 
94  $oiQuery = OldLocalFile::getQueryInfo();
95  return $db->select(
96  $oiQuery['tables'],
97  $oiQuery['fields'],
98  [
99  'oi_name' => $this->page->getDBkey(),
100  'oi_archive_name' => $archiveNames
101  ],
102  __METHOD__,
103  [ 'ORDER BY' => 'oi_timestamp DESC' ],
104  $oiQuery['joins']
105  );
106  }
107 
108  public function newItem( $row ) {
109  return new RevDelFileItem( $this, $row );
110  }
111 
112  public function clearFileOps() {
113  $this->deleteBatch = [];
114  $this->storeBatch = [];
115  $this->cleanupBatch = [];
116  }
117 
118  public function doPreCommitUpdates() {
119  $status = Status::newGood();
120  $repo = $this->repoGroup->getLocalRepo();
121  if ( $this->storeBatch ) {
122  $status->merge( $repo->storeBatch( $this->storeBatch, FileRepo::OVERWRITE_SAME ) );
123  }
124  if ( !$status->isOK() ) {
125  return $status;
126  }
127  if ( $this->deleteBatch ) {
128  $status->merge( $repo->deleteBatch( $this->deleteBatch ) );
129  }
130  if ( !$status->isOK() ) {
131  // Running cleanupDeletedBatch() after a failed storeBatch() with the DB already
132  // modified (but destined for rollback) causes data loss
133  return $status;
134  }
135  if ( $this->cleanupBatch ) {
136  $status->merge( $repo->cleanupDeletedBatch( $this->cleanupBatch ) );
137  }
138 
139  return $status;
140  }
141 
142  public function doPostCommitUpdates( array $visibilityChangeMap ) {
143  $file = $this->repoGroup->getLocalRepo()->newFile( $this->page );
144  $file->purgeCache();
145  $file->purgeDescription();
146 
147  // Purge full images from cache
148  $purgeUrls = [];
149  foreach ( $this->ids as $timestamp ) {
150  $archiveName = $timestamp . '!' . $this->page->getDBkey();
151  $file->purgeOldThumbnails( $archiveName );
152  $purgeUrls[] = $file->getArchiveUrl( $archiveName );
153  }
154 
155  $this->htmlCacheUpdater->purgeUrls(
156  $purgeUrls,
157  HtmlCacheUpdater::PURGE_INTENT_TXROUND_REFLECTED
158  );
159 
160  return Status::newGood();
161  }
162 
163  public function getSuppressBit() {
165  }
166 }
const OVERWRITE_SAME
Definition: FileRepo.php:51
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:30
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.
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.
PageIdentity $page
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:85
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:36
Result wrapper for grabbing data queried from an IDatabase object.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition: router.php:42