MediaWiki REL1_39
RevDelFileList.php
Go to the documentation of this file.
1<?php
25
30
32 private $htmlCacheUpdater;
33
35 private $repoGroup;
36
39
42
45
54 public function __construct(
55 IContextSource $context,
57 array $ids,
58 LBFactory $lbFactory,
59 HtmlCacheUpdater $htmlCacheUpdater,
60 RepoGroup $repoGroup
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() {
163 return File::DELETED_RESTRICTED;
164 }
165}
const OVERWRITE_SAME
Definition FileRepo.php:50
Class to invalidate the CDN and HTMLFileCache entries associated with URLs/titles.
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.
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.
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