MediaWiki REL1_27
RevDelRevisionList.php
Go to the documentation of this file.
1<?php
34
35 public function getType() {
36 return 'revision';
37 }
38
39 public static function getRelationType() {
40 return 'rev_id';
41 }
42
43 public static function getRestriction() {
44 return 'deleterevision';
45 }
46
47 public static function getRevdelConstant() {
49 }
50
51 public static function suggestTarget( $target, array $ids ) {
53 return $rev ? $rev->getTitle() : $target;
54 }
55
60 public function doQuery( $db ) {
61 $ids = array_map( 'intval', $this->ids );
62 $queryInfo = [
63 'tables' => [ 'revision', 'user' ],
64 'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ),
65 'conds' => [
66 'rev_page' => $this->title->getArticleID(),
67 'rev_id' => $ids,
68 ],
69 'options' => [ 'ORDER BY' => 'rev_id DESC' ],
70 'join_conds' => [
71 'page' => Revision::pageJoinCond(),
72 'user' => Revision::userJoinCond(),
73 ],
74 ];
76 $queryInfo['tables'],
77 $queryInfo['fields'],
78 $queryInfo['conds'],
79 $queryInfo['join_conds'],
80 $queryInfo['options'],
81 ''
82 );
83
84 $live = $db->select(
85 $queryInfo['tables'],
86 $queryInfo['fields'],
87 $queryInfo['conds'],
88 __METHOD__,
89 $queryInfo['options'],
90 $queryInfo['join_conds']
91 );
92 if ( $live->numRows() >= count( $ids ) ) {
93 // All requested revisions are live, keeps things simple!
94 return $live;
95 }
96
97 // Check if any requested revisions are available fully deleted.
98 $archived = $db->select( [ 'archive' ], Revision::selectArchiveFields(),
99 [
100 'ar_rev_id' => $ids
101 ],
102 __METHOD__,
103 [ 'ORDER BY' => 'ar_rev_id DESC' ]
104 );
105
106 if ( $archived->numRows() == 0 ) {
107 return $live;
108 } elseif ( $live->numRows() == 0 ) {
109 return $archived;
110 } else {
111 // Combine the two! Whee
112 $rows = [];
113 foreach ( $live as $row ) {
114 $rows[$row->rev_id] = $row;
115 }
116 foreach ( $archived as $row ) {
117 $rows[$row->ar_rev_id] = $row;
118 }
119 krsort( $rows );
120 return new FakeResultWrapper( array_values( $rows ) );
121 }
122 }
123
124 public function newItem( $row ) {
125 if ( isset( $row->rev_id ) ) {
126 return new RevDelRevisionItem( $this, $row );
127 } elseif ( isset( $row->ar_rev_id ) ) {
128 return new RevDelArchivedRevisionItem( $this, $row );
129 } else {
130 // This shouldn't happen. :)
131 throw new MWException( 'Invalid row type in RevDelRevisionList' );
132 }
133 }
134
135 public function getCurrent() {
136 if ( is_null( $this->currentRevId ) ) {
137 $dbw = wfGetDB( DB_MASTER );
138 $this->currentRevId = $dbw->selectField(
139 'page', 'page_latest', $this->title->pageCond(), __METHOD__ );
140 }
141 return $this->currentRevId;
142 }
143
144 public function getSuppressBit() {
146 }
147
148 public function doPreCommitUpdates() {
149 $this->title->invalidateCache();
150 return Status::newGood();
151 }
152
153 public function doPostCommitUpdates() {
154 $this->title->purgeSquid();
155 // Extensions that require referencing previous revisions may need this
156 Hooks::run( 'ArticleRevisionVisibilitySet', [ $this->title, $this->ids ] );
157 return Status::newGood();
158 }
159}
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag=false)
Applies all tags-related changes to a query.
Overloads the relevant methods of the real ResultsWrapper so it doesn't go anywhere near an actual da...
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.
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.
doPostCommitUpdates()
A hook for setVisibility(): do any necessary updates post-commit.
static selectArchiveFields()
Return the list of revision fields that should be selected to create a new revision from an archive r...
Definition Revision.php:460
static userJoinCond()
Return the value of a select() JOIN conds array for the user table.
Definition Revision.php:410
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
Definition Revision.php:429
static selectUserFields()
Return the list of user fields that should be selected from user table.
Definition Revision.php:517
static pageJoinCond()
Return the value of a select() page conds array for the page table.
Definition Revision.php:420
const DELETED_TEXT
Definition Revision.php:76
const DELETED_RESTRICTED
Definition Revision.php:79
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
Definition Revision.php:99
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
const DB_MASTER
Definition Defines.php:48
the array() calling protocol came about after MediaWiki 1.4rc1.
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:1597
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:37
title