Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
ChangeTagsLogList | |
0.00% |
0 / 16 |
|
0.00% |
0 / 4 |
42 | |
0.00% |
0 / 1 |
getType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
doQuery | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
newItem | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
updateChangeTagsOnAll | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
12 |
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 Change tagging |
20 | */ |
21 | |
22 | use MediaWiki\MediaWikiServices; |
23 | use MediaWiki\Permissions\Authority; |
24 | use MediaWiki\Status\Status; |
25 | use Wikimedia\Rdbms\IResultWrapper; |
26 | use Wikimedia\Rdbms\SelectQueryBuilder; |
27 | |
28 | /** |
29 | * Stores a list of taggable log entries. |
30 | * @since 1.25 |
31 | */ |
32 | class ChangeTagsLogList extends ChangeTagsList { |
33 | public function getType() { |
34 | return 'logentry'; |
35 | } |
36 | |
37 | /** |
38 | * @param \Wikimedia\Rdbms\IReadableDatabase $db |
39 | * @return IResultWrapper |
40 | */ |
41 | public function doQuery( $db ) { |
42 | $ids = array_map( 'intval', $this->ids ); |
43 | $queryBuilder = DatabaseLogEntry::newSelectQueryBuilder( $db ) |
44 | ->where( [ 'log_id' => $ids ] ) |
45 | ->orderBy( [ 'log_timestamp', 'log_id' ], SelectQueryBuilder::SORT_DESC ); |
46 | |
47 | MediaWikiServices::getInstance()->getChangeTagsStore()->modifyDisplayQueryBuilder( $queryBuilder, 'logging' ); |
48 | return $queryBuilder->caller( __METHOD__ )->fetchResultSet(); |
49 | } |
50 | |
51 | public function newItem( $row ) { |
52 | return new ChangeTagsLogItem( $this, $row ); |
53 | } |
54 | |
55 | /** |
56 | * Add/remove change tags from all the log entries in the list. |
57 | * |
58 | * @param string[] $tagsToAdd |
59 | * @param string[] $tagsToRemove |
60 | * @param string|null $params |
61 | * @param string $reason |
62 | * @param Authority $performer |
63 | * @return Status |
64 | */ |
65 | public function updateChangeTagsOnAll( |
66 | array $tagsToAdd, |
67 | array $tagsToRemove, |
68 | ?string $params, |
69 | string $reason, |
70 | Authority $performer |
71 | ) { |
72 | $status = Status::newGood(); |
73 | for ( $this->reset(); $this->current(); $this->next() ) { |
74 | $item = $this->current(); |
75 | $status = ChangeTags::updateTagsWithChecks( $tagsToAdd, $tagsToRemove, |
76 | null, null, $item->getId(), $params, $reason, $performer ); |
77 | // Should only fail on second and subsequent times if the user trips |
78 | // the rate limiter |
79 | if ( !$status->isOK() ) { |
80 | break; |
81 | } |
82 | } |
83 | |
84 | return $status; |
85 | } |
86 | } |