MediaWiki master
RevDelLogList.php
Go to the documentation of this file.
1<?php
32
37
38 protected const SUPPRESS_BIT = LogPage::DELETED_RESTRICTED;
39
41 private $commentStore;
42 private LogFormatterFactory $logFormatterFactory;
43
53 public function __construct(
54 IContextSource $context,
55 PageIdentity $page,
56 array $ids,
57 LBFactory $lbFactory,
58 CommentStore $commentStore,
59 LogFormatterFactory $logFormatterFactory
60 ) {
61 parent::__construct( $context, $page, $ids, $lbFactory );
62 $this->commentStore = $commentStore;
63 $this->logFormatterFactory = $logFormatterFactory;
64 }
65
66 public function getType() {
67 return 'logging';
68 }
69
70 public static function getRelationType() {
71 return 'log_id';
72 }
73
74 public static function getRestriction() {
75 return 'deletelogentry';
76 }
77
78 public static function getRevdelConstant() {
79 return LogPage::DELETED_ACTION;
80 }
81
82 public static function suggestTarget( $target, array $ids ) {
83 $dbr = MediaWikiServices::getInstance()->getConnectionProvider()->getReplicaDatabase();
84 $result = $dbr->newSelectQueryBuilder()
85 ->select( 'log_type' )
86 ->distinct()
87 ->from( 'logging' )
88 ->where( [ 'log_id' => $ids ] )
89 ->caller( __METHOD__ )->fetchResultSet();
90 if ( $result->numRows() == 1 ) {
91 // If there's only one type, the target can be set to include it.
92 return SpecialPage::getTitleFor( 'Log', $result->current()->log_type );
93 }
94
95 return SpecialPage::getTitleFor( 'Log' );
96 }
97
102 public function doQuery( $db ) {
103 $ids = array_map( 'intval', $this->ids );
104 $queryBuilder = $db->newSelectQueryBuilder()
105 ->select( [
106 'log_id',
107 'log_type',
108 'log_action',
109 'log_timestamp',
110 'log_actor',
111 'log_namespace',
112 'log_title',
113 'log_page',
114 'log_params',
115 'log_deleted',
116 'log_user' => 'actor_user',
117 'log_user_text' => 'actor_name',
118 'log_comment_text' => 'comment_log_comment.comment_text',
119 'log_comment_data' => 'comment_log_comment.comment_data',
120 'log_comment_cid' => 'comment_log_comment.comment_id'
121 ] )
122 ->from( 'logging' )
123 ->join( 'actor', null, 'actor_id=log_actor' )
124 ->join( 'comment', 'comment_log_comment', 'comment_log_comment.comment_id = log_comment_id' )
125 ->where( [ 'log_id' => $ids ] )
126 ->orderBy( [ 'log_timestamp', 'log_id' ], SelectQueryBuilder::SORT_DESC );
127
128 MediaWikiServices::getInstance()->getChangeTagsStore()->modifyDisplayQueryBuilder( $queryBuilder, 'logging' );
129
130 return $queryBuilder->caller( __METHOD__ )->fetchResultSet();
131 }
132
133 public function newItem( $row ) {
134 return new RevDelLogItem(
135 $this,
136 $row,
137 $this->commentStore,
138 MediaWikiServices::getInstance()->getConnectionProvider(),
139 $this->logFormatterFactory
140 );
141 }
142
143 public function getLogAction() {
144 return 'event';
145 }
146
147 public function getLogParams( $params ) {
148 return [
149 '4::ids' => $params['ids'],
150 '5::ofield' => $params['oldBits'],
151 '6::nfield' => $params['newBits'],
152 ];
153 }
154}
Handle database storage of comments such as edit summaries and log reasons.
Class to simplify the use of log pages.
Definition LogPage.php:50
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.
__construct(IContextSource $context, PageIdentity $page, array $ids, LBFactory $lbFactory, CommentStore $commentStore, LogFormatterFactory $logFormatterFactory)
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.
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.