MediaWiki  1.30.0
RevDelRevisionList.php
Go to the documentation of this file.
1 <?php
24 
36  public $currentRevId;
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() {
52  }
53 
54  public static function suggestTarget( $target, array $ids ) {
56  return $rev ? $rev->getTitle() : $target;
57  }
58 
63  public function doQuery( $db ) {
64  $ids = array_map( 'intval', $this->ids );
65  $queryInfo = [
66  'tables' => [ 'revision', 'page', 'user' ],
67  'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ),
68  'conds' => [
69  'rev_page' => $this->title->getArticleID(),
70  'rev_id' => $ids,
71  ],
72  'options' => [
73  'ORDER BY' => 'rev_id DESC',
74  'USE INDEX' => [ 'revision' => 'PRIMARY' ] // workaround for MySQL bug (T104313)
75  ],
76  'join_conds' => [
77  'page' => Revision::pageJoinCond(),
78  'user' => Revision::userJoinCond(),
79  ],
80  ];
82  $queryInfo['tables'],
83  $queryInfo['fields'],
84  $queryInfo['conds'],
85  $queryInfo['join_conds'],
86  $queryInfo['options'],
87  ''
88  );
89 
90  $live = $db->select(
91  $queryInfo['tables'],
92  $queryInfo['fields'],
93  $queryInfo['conds'],
94  __METHOD__,
95  $queryInfo['options'],
96  $queryInfo['join_conds']
97  );
98  if ( $live->numRows() >= count( $ids ) ) {
99  // All requested revisions are live, keeps things simple!
100  return $live;
101  }
102 
103  $archiveQueryInfo = [
104  'tables' => [ 'archive' ],
105  'fields' => Revision::selectArchiveFields(),
106  'conds' => [
107  'ar_rev_id' => $ids,
108  ],
109  'options' => [ 'ORDER BY' => 'ar_rev_id DESC' ],
110  'join_conds' => [],
111  ];
112 
114  $archiveQueryInfo['tables'],
115  $archiveQueryInfo['fields'],
116  $archiveQueryInfo['conds'],
117  $archiveQueryInfo['join_conds'],
118  $archiveQueryInfo['options'],
119  ''
120  );
121 
122  // Check if any requested revisions are available fully deleted.
123  $archived = $db->select(
124  $archiveQueryInfo['tables'],
125  $archiveQueryInfo['fields'],
126  $archiveQueryInfo['conds'],
127  __METHOD__,
128  $archiveQueryInfo['options'],
129  $archiveQueryInfo['join_conds']
130  );
131 
132  if ( $archived->numRows() == 0 ) {
133  return $live;
134  } elseif ( $live->numRows() == 0 ) {
135  return $archived;
136  } else {
137  // Combine the two! Whee
138  $rows = [];
139  foreach ( $live as $row ) {
140  $rows[$row->rev_id] = $row;
141  }
142  foreach ( $archived as $row ) {
143  $rows[$row->ar_rev_id] = $row;
144  }
145  krsort( $rows );
146  return new FakeResultWrapper( array_values( $rows ) );
147  }
148  }
149 
150  public function newItem( $row ) {
151  if ( isset( $row->rev_id ) ) {
152  return new RevDelRevisionItem( $this, $row );
153  } elseif ( isset( $row->ar_rev_id ) ) {
154  return new RevDelArchivedRevisionItem( $this, $row );
155  } else {
156  // This shouldn't happen. :)
157  throw new MWException( 'Invalid row type in RevDelRevisionList' );
158  }
159  }
160 
161  public function getCurrent() {
162  if ( is_null( $this->currentRevId ) ) {
163  $dbw = wfGetDB( DB_MASTER );
164  $this->currentRevId = $dbw->selectField(
165  'page', 'page_latest', $this->title->pageCond(), __METHOD__ );
166  }
167  return $this->currentRevId;
168  }
169 
170  public function getSuppressBit() {
172  }
173 
174  public function doPreCommitUpdates() {
175  $this->title->invalidateCache();
176  return Status::newGood();
177  }
178 
179  public function doPostCommitUpdates( array $visibilityChangeMap ) {
180  $this->title->purgeSquid();
181  // Extensions that require referencing previous revisions may need this
182  Hooks::run( 'ArticleRevisionVisibilitySet', [ $this->title, $this->ids, $visibilityChangeMap ] );
183  return Status::newGood();
184  }
185 }
RevDelRevisionList\doPreCommitUpdates
doPreCommitUpdates()
A hook for setVisibility(): do batch updates pre-commit.
Definition: RevDelRevisionList.php:174
Revision\DELETED_RESTRICTED
const DELETED_RESTRICTED
Definition: Revision.php:93
Revision\newFromId
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
Definition: Revision.php:116
Revision\pageJoinCond
static pageJoinCond()
Return the value of a select() page conds array for the page table.
Definition: Revision.php:441
captcha-old.count
count
Definition: captcha-old.py:249
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
RevDelRevisionList\doPostCommitUpdates
doPostCommitUpdates(array $visibilityChangeMap)
A hook for setVisibility(): do any necessary updates post-commit.
Definition: RevDelRevisionList.php:179
Wikimedia\Rdbms\FakeResultWrapper
Overloads the relevant methods of the real ResultsWrapper so it doesn't go anywhere near an actual da...
Definition: FakeResultWrapper.php:11
RevDelRevisionList\getType
getType()
Get the internal type name of this list.
Definition: RevDelRevisionList.php:38
RevDelRevisionList\$currentRevId
int $currentRevId
Definition: RevDelRevisionList.php:36
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:40
title
to move a page</td >< td > &*You are moving the page across *A non empty talk page already exists under the new or *You uncheck the box below In those you will have to move or merge the page manually if desired</td >< td > be sure to &You are responsible for making sure that links continue to point where they are supposed to go Note that the page will &a page at the new title
Definition: All_system_messages.txt:2696
ChangeTags\modifyDisplayQuery
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag='')
Applies all tags-related changes to a query.
Definition: ChangeTags.php:661
MWException
MediaWiki exception.
Definition: MWException.php:26
RevDelRevisionList\getCurrent
getCurrent()
Definition: RevDelRevisionList.php:161
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2856
RevDelRevisionList\getRelationType
static getRelationType()
Get the DB field name associated with the ID list.
Definition: RevDelRevisionList.php:42
RevDelRevisionList
List for revision table items.
Definition: RevDelRevisionList.php:34
RevDelList
Abstract base class for a list of deletable items.
Definition: RevDelList.php:30
DB_MASTER
const DB_MASTER
Definition: defines.php:26
RevDelRevisionList\getRevdelConstant
static getRevdelConstant()
Get the revision deletion constant for this list type Override this function.
Definition: RevDelRevisionList.php:50
Revision\selectArchiveFields
static selectArchiveFields()
Return the list of revision fields that should be selected to create a new revision from an archive r...
Definition: Revision.php:486
StatusValue\newGood
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:81
RevisionListBase\$ids
array $ids
Definition: RevisionList.php:35
RevDelRevisionList\getSuppressBit
getSuppressBit()
Get the integer value of the flag used for suppression.
Definition: RevDelRevisionList.php:170
RevDelRevisionList\doQuery
doQuery( $db)
Definition: RevDelRevisionList.php:63
RevDelRevisionList\getRestriction
static getRestriction()
Get the user right required for this list type Override this function.
Definition: RevDelRevisionList.php:46
RevDelArchivedRevisionItem
Item class for a archive table row by ar_rev_id – actually used via RevDelRevisionList.
Definition: RevDelArchivedRevisionItem.php:26
$rows
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:2581
$rev
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:1750
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Revision\userJoinCond
static userJoinCond()
Return the value of a select() JOIN conds array for the user table.
Definition: Revision.php:431
RevDelRevisionItem
Item class for a live revision table row.
Definition: RevDelRevisionItem.php:25
Revision\selectUserFields
static selectUserFields()
Return the list of user fields that should be selected from user table.
Definition: Revision.php:544
RevDelRevisionList\newItem
newItem( $row)
Create an item object from a DB result row.
Definition: RevDelRevisionList.php:150
Revision\selectFields
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
Definition: Revision.php:452
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:203
RevDelRevisionList\suggestTarget
static suggestTarget( $target, array $ids)
Suggest a target for the revision deletion Optionally override this function.
Definition: RevDelRevisionList.php:54
Revision\DELETED_TEXT
const DELETED_TEXT
Definition: Revision.php:90
array
the array() calling protocol came about after MediaWiki 1.4rc1.