Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 18 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
ChangeTagsRevisionList | |
0.00% |
0 / 18 |
|
0.00% |
0 / 4 |
42 | |
0.00% |
0 / 1 |
getType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
doQuery | |
0.00% |
0 / 8 |
|
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 revisions. |
30 | * @since 1.25 |
31 | */ |
32 | class ChangeTagsRevisionList extends ChangeTagsList { |
33 | public function getType() { |
34 | return 'revision'; |
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 = MediaWikiServices::getInstance()->getRevisionStore()->newSelectQueryBuilder( $db ) |
44 | ->joinComment() |
45 | ->joinUser() |
46 | ->where( [ 'rev_page' => $this->page->getId(), 'rev_id' => $ids ] ) |
47 | ->orderBy( 'rev_id', SelectQueryBuilder::SORT_DESC ); |
48 | |
49 | MediaWikiServices::getInstance()->getChangeTagsStore()->modifyDisplayQueryBuilder( $queryBuilder, 'revision' ); |
50 | return $queryBuilder->caller( __METHOD__ )->fetchResultSet(); |
51 | } |
52 | |
53 | public function newItem( $row ) { |
54 | return new ChangeTagsRevisionItem( $this, $row ); |
55 | } |
56 | |
57 | /** |
58 | * Add/remove change tags from all the revisions in the list. |
59 | * |
60 | * @param string[] $tagsToAdd |
61 | * @param string[] $tagsToRemove |
62 | * @param string|null $params |
63 | * @param string $reason |
64 | * @param Authority $performer |
65 | * @return Status |
66 | */ |
67 | public function updateChangeTagsOnAll( |
68 | array $tagsToAdd, |
69 | array $tagsToRemove, |
70 | ?string $params, |
71 | string $reason, |
72 | Authority $performer |
73 | ) { |
74 | $status = Status::newGood(); |
75 | for ( $this->reset(); $this->current(); $this->next() ) { |
76 | $item = $this->current(); |
77 | $status = ChangeTags::updateTagsWithChecks( $tagsToAdd, $tagsToRemove, |
78 | null, $item->getId(), null, $params, $reason, $performer ); |
79 | // Should only fail on second and subsequent times if the user trips |
80 | // the rate limiter |
81 | if ( !$status->isOK() ) { |
82 | break; |
83 | } |
84 | } |
85 | |
86 | return $status; |
87 | } |
88 | } |