Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 54 |
|
0.00% |
0 / 10 |
CRAP | |
0.00% |
0 / 1 |
RevDelLogList | |
0.00% |
0 / 54 |
|
0.00% |
0 / 10 |
132 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getRelationType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getRestriction | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getRevdelConstant | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
suggestTarget | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
6 | |||
doQuery | |
0.00% |
0 / 26 |
|
0.00% |
0 / 1 |
2 | |||
newItem | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
getLogAction | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getLogParams | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
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. |
7 | * |
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. |
12 | * |
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 |
17 | * |
18 | * @file |
19 | * @ingroup RevisionDelete |
20 | */ |
21 | |
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; |
30 | |
31 | /** |
32 | * List for logging table items |
33 | */ |
34 | class RevDelLogList extends RevDelList { |
35 | |
36 | protected const SUPPRESS_BIT = LogPage::DELETED_RESTRICTED; |
37 | |
38 | /** @var CommentStore */ |
39 | private $commentStore; |
40 | |
41 | /** |
42 | * @internal Use RevisionDeleter |
43 | * @param IContextSource $context |
44 | * @param PageIdentity $page |
45 | * @param array $ids |
46 | * @param LBFactory $lbFactory |
47 | * @param CommentStore $commentStore |
48 | */ |
49 | public function __construct( |
50 | IContextSource $context, |
51 | PageIdentity $page, |
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 | |
92 | /** |
93 | * @param \Wikimedia\Rdbms\IReadableDatabase $db |
94 | * @return IResultWrapper |
95 | */ |
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 | } |