3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
19 * @ingroup RevisionDelete
22 use MediaWiki\CommentStore\CommentStore
;
23 use MediaWiki\Context\IContextSource
;
24 use MediaWiki\MediaWikiServices
;
25 use MediaWiki\Page\PageIdentity
;
26 use MediaWiki\SpecialPage\SpecialPage
;
27 use Wikimedia\Rdbms\IResultWrapper
;
28 use Wikimedia\Rdbms\LBFactory
;
29 use Wikimedia\Rdbms\SelectQueryBuilder
;
32 * List for logging table items
34 class RevDelLogList
extends RevDelList
{
36 protected const SUPPRESS_BIT
= LogPage
::DELETED_RESTRICTED
;
38 /** @var CommentStore */
39 private $commentStore;
40 private LogFormatterFactory
$logFormatterFactory;
43 * @internal Use RevisionDeleter
44 * @param IContextSource $context
45 * @param PageIdentity $page
47 * @param LBFactory $lbFactory
48 * @param CommentStore $commentStore
49 * @param LogFormatterFactory $logFormatterFactory
51 public function __construct(
52 IContextSource
$context,
56 CommentStore
$commentStore,
57 LogFormatterFactory
$logFormatterFactory
59 parent
::__construct( $context, $page, $ids, $lbFactory );
60 $this->commentStore
= $commentStore;
61 $this->logFormatterFactory
= $logFormatterFactory;
64 public function getType() {
68 public static function getRelationType() {
72 public static function getRestriction() {
73 return 'deletelogentry';
76 public static function getRevdelConstant() {
77 return LogPage
::DELETED_ACTION
;
80 public static function suggestTarget( $target, array $ids ) {
81 $dbr = MediaWikiServices
::getInstance()->getConnectionProvider()->getReplicaDatabase();
82 $result = $dbr->newSelectQueryBuilder()
83 ->select( 'log_type' )
86 ->where( [ 'log_id' => $ids ] )
87 ->caller( __METHOD__
)->fetchResultSet();
88 if ( $result->numRows() == 1 ) {
89 // If there's only one type, the target can be set to include it.
90 return SpecialPage
::getTitleFor( 'Log', $result->current()->log_type
);
93 return SpecialPage
::getTitleFor( 'Log' );
97 * @param \Wikimedia\Rdbms\IReadableDatabase $db
98 * @return IResultWrapper
100 public function doQuery( $db ) {
101 $ids = array_map( 'intval', $this->ids
);
102 $queryBuilder = $db->newSelectQueryBuilder()
114 'log_user' => 'actor_user',
115 'log_user_text' => 'actor_name',
116 'log_comment_text' => 'comment_log_comment.comment_text',
117 'log_comment_data' => 'comment_log_comment.comment_data',
118 'log_comment_cid' => 'comment_log_comment.comment_id'
121 ->join( 'actor', null, 'actor_id=log_actor' )
122 ->join( 'comment', 'comment_log_comment', 'comment_log_comment.comment_id = log_comment_id' )
123 ->where( [ 'log_id' => $ids ] )
124 ->orderBy( [ 'log_timestamp', 'log_id' ], SelectQueryBuilder
::SORT_DESC
);
126 MediaWikiServices
::getInstance()->getChangeTagsStore()->modifyDisplayQueryBuilder( $queryBuilder, 'logging' );
128 return $queryBuilder->caller( __METHOD__
)->fetchResultSet();
131 public function newItem( $row ) {
132 return new RevDelLogItem(
136 MediaWikiServices
::getInstance()->getConnectionProvider(),
137 $this->logFormatterFactory
141 public function getLogAction() {
145 public function getLogParams( $params ) {
147 '4::ids' => $params['ids'],
148 '5::ofield' => $params['oldBits'],
149 '6::nfield' => $params['newBits'],