MediaWiki master
RevDelLogList.php
Go to the documentation of this file.
1<?php
30
35
36 protected const SUPPRESS_BIT = LogPage::DELETED_RESTRICTED;
37
39 private $commentStore;
40
49 public function __construct(
50 IContextSource $context,
52 array $ids,
53 LBFactory $lbFactory,
54 CommentStore $commentStore
55 ) {
56 parent::__construct( $context, $page, $ids, $lbFactory );
57 $this->commentStore = $commentStore;
58 }
59
60 public function getType() {
61 return 'logging';
62 }
63
64 public static function getRelationType() {
65 return 'log_id';
66 }
67
68 public static function getRestriction() {
69 return 'deletelogentry';
70 }
71
72 public static function getRevdelConstant() {
73 return LogPage::DELETED_ACTION;
74 }
75
76 public static function suggestTarget( $target, array $ids ) {
77 $dbr = MediaWikiServices::getInstance()->getConnectionProvider()->getReplicaDatabase();
78 $result = $dbr->newSelectQueryBuilder()
79 ->select( 'log_type' )
80 ->distinct()
81 ->from( 'logging' )
82 ->where( [ 'log_id' => $ids ] )
83 ->caller( __METHOD__ )->fetchResultSet();
84 if ( $result->numRows() == 1 ) {
85 // If there's only one type, the target can be set to include it.
86 return SpecialPage::getTitleFor( 'Log', $result->current()->log_type );
87 }
88
89 return SpecialPage::getTitleFor( 'Log' );
90 }
91
96 public function doQuery( $db ) {
97 $ids = array_map( 'intval', $this->ids );
98 $queryBuilder = $db->newSelectQueryBuilder()
99 ->select( [
100 'log_id',
101 'log_type',
102 'log_action',
103 'log_timestamp',
104 'log_actor',
105 'log_namespace',
106 'log_title',
107 'log_page',
108 'log_params',
109 'log_deleted',
110 'log_user' => 'actor_user',
111 'log_user_text' => 'actor_name',
112 'log_comment_text' => 'comment_log_comment.comment_text',
113 'log_comment_data' => 'comment_log_comment.comment_data',
114 'log_comment_cid' => 'comment_log_comment.comment_id'
115 ] )
116 ->from( 'logging' )
117 ->join( 'actor', null, 'actor_id=log_actor' )
118 ->join( 'comment', 'comment_log_comment', 'comment_log_comment.comment_id = log_comment_id' )
119 ->where( [ 'log_id' => $ids ] )
120 ->orderBy( [ 'log_timestamp', 'log_id' ], SelectQueryBuilder::SORT_DESC );
121
122 MediaWikiServices::getInstance()->getChangeTagsStore()->modifyDisplayQueryBuilder( $queryBuilder, 'logging' );
123
124 return $queryBuilder->caller( __METHOD__ )->fetchResultSet();
125 }
126
127 public function newItem( $row ) {
128 return new RevDelLogItem(
129 $this,
130 $row,
131 $this->commentStore,
132 MediaWikiServices::getInstance()->getConnectionProvider()
133 );
134 }
135
136 public function getLogAction() {
137 return 'event';
138 }
139
140 public function getLogParams( $params ) {
141 return [
142 '4::ids' => $params['ids'],
143 '5::ofield' => $params['oldBits'],
144 '6::nfield' => $params['newBits'],
145 ];
146 }
147}
array $params
The job parameters.
Handle database storage of comments such as edit summaries and log reasons.
Service locator for MediaWiki core services.
Parent class for all special pages.
Item class for a logging table row.
List for logging table items.
getLogParams( $params)
Get log parameter array.
getLogAction()
Get the log action for this list type.
static getRestriction()
Get the user right required for this list type Override this function.
static getRelationType()
Get the DB field name associated with the ID list.
getType()
Get the internal type name of this list.
static suggestTarget( $target, array $ids)
Suggest a target for the revision deletion Optionally override this function.
static getRevdelConstant()
Get the revision deletion constant for this list type Override this function.
newItem( $row)
Create an item object from a DB result row.
__construct(IContextSource $context, PageIdentity $page, array $ids, LBFactory $lbFactory, CommentStore $commentStore)
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.
Result wrapper for grabbing data queried from an IDatabase object.