MediaWiki master
RevDelFileList.php
Go to the documentation of this file.
1<?php
9
22
27
28 protected const SUPPRESS_BIT = File::DELETED_RESTRICTED;
29
31 private $htmlCacheUpdater;
32
34 private $repoGroup;
35
38
41
44
53 public function __construct(
54 IContextSource $context,
56 array $ids,
57 LBFactory $lbFactory,
58 HTMLCacheUpdater $htmlCacheUpdater,
59 RepoGroup $repoGroup
60 ) {
61 parent::__construct( $context, $page, $ids, $lbFactory );
62 $this->htmlCacheUpdater = $htmlCacheUpdater;
63 $this->repoGroup = $repoGroup;
64 }
65
67 public function getType() {
68 return 'oldimage';
69 }
70
72 public static function getRelationType() {
73 return 'oi_archive_name';
74 }
75
77 public static function getRestriction() {
78 return 'deleterevision';
79 }
80
82 public static function getRevdelConstant() {
83 return File::DELETED_FILE;
84 }
85
90 public function doQuery( $db ) {
91 $archiveNames = [];
92 foreach ( $this->ids as $timestamp ) {
93 $archiveNames[] = $timestamp . '!' . $this->page->getDBkey();
94 }
95
96 $queryBuilder = FileSelectQueryBuilder::newForOldFile( $db );
97 $queryBuilder
98 ->where( [ 'oi_name' => $this->page->getDBkey(), 'oi_archive_name' => $archiveNames ] )
99 ->orderBy( 'oi_timestamp', SelectQueryBuilder::SORT_DESC );
100 return $queryBuilder->caller( __METHOD__ )->fetchResultSet();
101 }
102
104 public function newItem( $row ) {
105 return new RevDelFileItem( $this, $row );
106 }
107
108 public function clearFileOps() {
109 $this->deleteBatch = [];
110 $this->storeBatch = [];
111 $this->cleanupBatch = [];
112 }
113
115 public function doPreCommitUpdates() {
116 $status = Status::newGood();
117 $repo = $this->repoGroup->getLocalRepo();
118 if ( $this->storeBatch ) {
119 $status->merge( $repo->storeBatch( $this->storeBatch, FileRepo::OVERWRITE_SAME ) );
120 }
121 if ( !$status->isOK() ) {
122 return $status;
123 }
124 if ( $this->deleteBatch ) {
125 $status->merge( $repo->deleteBatch( $this->deleteBatch ) );
126 }
127 if ( !$status->isOK() ) {
128 // Running cleanupDeletedBatch() after a failed storeBatch() with the DB already
129 // modified (but destined for rollback) causes data loss
130 return $status;
131 }
132 if ( $this->cleanupBatch ) {
133 $status->merge( $repo->cleanupDeletedBatch( $this->cleanupBatch ) );
134 }
135
136 return $status;
137 }
138
140 public function doPostCommitUpdates( array $visibilityChangeMap ) {
141 $file = $this->repoGroup->getLocalRepo()->newFile( $this->page );
142 $file->purgeCache();
143 $file->purgeDescription();
144
145 // Purge full images from cache
146 $purgeUrls = [];
147 foreach ( $this->ids as $timestamp ) {
148 $archiveName = $timestamp . '!' . $this->page->getDBkey();
149 $file->purgeOldThumbnails( $archiveName );
150 $purgeUrls[] = $file->getArchiveUrl( $archiveName );
151 }
152
153 $this->htmlCacheUpdater->purgeUrls(
154 $purgeUrls,
155 HTMLCacheUpdater::PURGE_INTENT_TXROUND_REFLECTED
156 );
157
158 return Status::newGood();
159 }
160
161}
162
164class_alias( RevDelFileList::class, 'RevDelFileList' );
Class to invalidate the CDN and HTMLFileCache entries associated with URLs/titles.
Base class for file repositories.
Definition FileRepo.php:51
Implements some public methods and some protected utility functions which are required by multiple ch...
Definition File.php:79
Prioritized list of file repositories.
Definition RepoGroup.php:30
Item class for an oldimage table row.
List for oldimage table items.
static getRestriction()
Get the user right required for this list type Override this function.1.22 string|null
static getRelationType()
Get the DB field name associated with the ID list.This used to populate the log_search table for find...
__construct(IContextSource $context, PageIdentity $page, array $ids, LBFactory $lbFactory, HTMLCacheUpdater $htmlCacheUpdater, RepoGroup $repoGroup)
newItem( $row)
Create an item object from a DB result row.RevisionItemBase
doPreCommitUpdates()
A hook for setVisibility(): do batch updates pre-commit.STUB Status
clearFileOps()
Clear any data structures needed for doPreCommitUpdates() and doPostCommitUpdates() STUB.
static getRevdelConstant()
Get the revision deletion constant for this list type Override this function.1.22 int|null
doPostCommitUpdates(array $visibilityChangeMap)
A hook for setVisibility(): do any necessary updates post-commit.STUB Status
getType()
Get the internal type name of this list.Equal to the table name. Override this function....
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition Status.php:44
Build SELECT queries with a fluent interface.
Interface for objects which can provide a MediaWiki context on request.
Interface for objects (potentially) representing an editable wiki page.
A database connection without write operations.
Result wrapper for grabbing data queried from an IDatabase object.