MediaWiki REL1_31
RevDelRevisionList.php
Go to the documentation of this file.
1<?php
24
37
38 public function getType() {
39 return 'revision';
40 }
41
42 public static function getRelationType() {
43 return 'rev_id';
44 }
45
46 public static function getRestriction() {
47 return 'deleterevision';
48 }
49
50 public static function getRevdelConstant() {
51 return Revision::DELETED_TEXT;
52 }
53
54 public static function suggestTarget( $target, array $ids ) {
55 $rev = Revision::newFromId( $ids[0] );
56 return $rev ? $rev->getTitle() : $target;
57 }
58
63 public function doQuery( $db ) {
64 $ids = array_map( 'intval', $this->ids );
65 $revQuery = Revision::getQueryInfo( [ 'page', 'user' ] );
66 $queryInfo = [
67 'tables' => $revQuery['tables'],
68 'fields' => $revQuery['fields'],
69 'conds' => [
70 'rev_page' => $this->title->getArticleID(),
71 'rev_id' => $ids,
72 ],
73 'options' => [
74 'ORDER BY' => 'rev_id DESC',
75 'USE INDEX' => [ 'revision' => 'PRIMARY' ] // workaround for MySQL bug (T104313)
76 ],
77 'join_conds' => $revQuery['joins'],
78 ];
80 $queryInfo['tables'],
81 $queryInfo['fields'],
82 $queryInfo['conds'],
83 $queryInfo['join_conds'],
84 $queryInfo['options'],
85 ''
86 );
87
88 $live = $db->select(
89 $queryInfo['tables'],
90 $queryInfo['fields'],
91 $queryInfo['conds'],
92 __METHOD__,
93 $queryInfo['options'],
94 $queryInfo['join_conds']
95 );
96 if ( $live->numRows() >= count( $ids ) ) {
97 // All requested revisions are live, keeps things simple!
98 return $live;
99 }
100
101 $arQuery = Revision::getArchiveQueryInfo();
102 $archiveQueryInfo = [
103 'tables' => $arQuery['tables'],
104 'fields' => $arQuery['fields'],
105 'conds' => [
106 'ar_rev_id' => $ids,
107 ],
108 'options' => [ 'ORDER BY' => 'ar_rev_id DESC' ],
109 'join_conds' => $arQuery['joins'],
110 ];
111
113 $archiveQueryInfo['tables'],
114 $archiveQueryInfo['fields'],
115 $archiveQueryInfo['conds'],
116 $archiveQueryInfo['join_conds'],
117 $archiveQueryInfo['options'],
118 ''
119 );
120
121 // Check if any requested revisions are available fully deleted.
122 $archived = $db->select(
123 $archiveQueryInfo['tables'],
124 $archiveQueryInfo['fields'],
125 $archiveQueryInfo['conds'],
126 __METHOD__,
127 $archiveQueryInfo['options'],
128 $archiveQueryInfo['join_conds']
129 );
130
131 if ( $archived->numRows() == 0 ) {
132 return $live;
133 } elseif ( $live->numRows() == 0 ) {
134 return $archived;
135 } else {
136 // Combine the two! Whee
137 $rows = [];
138 foreach ( $live as $row ) {
139 $rows[$row->rev_id] = $row;
140 }
141 foreach ( $archived as $row ) {
142 $rows[$row->ar_rev_id] = $row;
143 }
144 krsort( $rows );
145 return new FakeResultWrapper( array_values( $rows ) );
146 }
147 }
148
149 public function newItem( $row ) {
150 if ( isset( $row->rev_id ) ) {
151 return new RevDelRevisionItem( $this, $row );
152 } elseif ( isset( $row->ar_rev_id ) ) {
153 return new RevDelArchivedRevisionItem( $this, $row );
154 } else {
155 // This shouldn't happen. :)
156 throw new MWException( 'Invalid row type in RevDelRevisionList' );
157 }
158 }
159
160 public function getCurrent() {
161 if ( is_null( $this->currentRevId ) ) {
162 $dbw = wfGetDB( DB_MASTER );
163 $this->currentRevId = $dbw->selectField(
164 'page', 'page_latest', $this->title->pageCond(), __METHOD__ );
165 }
166 return $this->currentRevId;
167 }
168
169 public function getSuppressBit() {
170 return Revision::DELETED_RESTRICTED;
171 }
172
173 public function doPreCommitUpdates() {
174 $this->title->invalidateCache();
175 return Status::newGood();
176 }
177
178 public function doPostCommitUpdates( array $visibilityChangeMap ) {
179 $this->title->purgeSquid();
180 // Extensions that require referencing previous revisions may need this
181 Hooks::run( 'ArticleRevisionVisibilitySet', [ $this->title, $this->ids, $visibilityChangeMap ] );
182 return Status::newGood();
183 }
184}
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag='')
Applies all tags-related changes to a query.
MediaWiki exception.
Item class for a archive table row by ar_rev_id – actually used via RevDelRevisionList.
Abstract base class for a list of deletable items.
Item class for a live revision table row.
List for revision table items.
getSuppressBit()
Get the integer value of the flag used for suppression.
doPostCommitUpdates(array $visibilityChangeMap)
A hook for setVisibility(): do any necessary updates post-commit.
static getRevdelConstant()
Get the revision deletion constant for this list type Override this function.
static getRelationType()
Get the DB field name associated with the ID list.
static suggestTarget( $target, array $ids)
Suggest a target for the revision deletion Optionally override this function.
static getRestriction()
Get the user right required for this list type Override this function.
doPreCommitUpdates()
A hook for setVisibility(): do batch updates pre-commit.
getType()
Get the internal type name of this list.
newItem( $row)
Create an item object from a DB result row.
Overloads the relevant methods of the real ResultsWrapper so it doesn't go anywhere near an actual da...
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction $rows
Definition hooks.txt:2783
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Definition hooks.txt:1777
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38
const DB_MASTER
Definition defines.php:29