Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
83.33% covered (warning)
83.33%
10 / 12
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
ChangeTagsList
83.33% covered (warning)
83.33%
10 / 12
66.67% covered (warning)
66.67%
2 / 3
6.17
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 factory
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
4
 reloadFromPrimary
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 updateChangeTagsOnAll
n/a
0 / 0
n/a
0 / 0
0
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
22use MediaWiki\Context\IContextSource;
23use MediaWiki\MediaWikiServices;
24use MediaWiki\Page\PageIdentity;
25use MediaWiki\Permissions\Authority;
26use MediaWiki\Status\Status;
27
28/**
29 * Generic list for change tagging.
30 *
31 * @property ChangeTagsLogItem $current
32 * @method ChangeTagsLogItem next()
33 * @method ChangeTagsLogItem reset()
34 * @method ChangeTagsLogItem current()
35 */
36abstract class ChangeTagsList extends RevisionListBase {
37    public function __construct( IContextSource $context, PageIdentity $page, array $ids ) {
38        parent::__construct( $context, $page );
39        $this->ids = $ids;
40    }
41
42    /**
43     * Creates a ChangeTags*List of the requested type.
44     *
45     * @param string $typeName 'revision' or 'logentry'
46     * @param IContextSource $context
47     * @param PageIdentity $page
48     * @param array $ids
49     * @return ChangeTagsList An instance of the requested subclass
50     * @throws InvalidArgumentException If you give an unknown $typeName
51     */
52    public static function factory( $typeName, IContextSource $context,
53        PageIdentity $page, array $ids
54    ) {
55        switch ( $typeName ) {
56            case 'revision':
57                $className = ChangeTagsRevisionList::class;
58                break;
59            case 'logentry':
60                $className = ChangeTagsLogList::class;
61                break;
62            default:
63                throw new InvalidArgumentException( "Class $typeName requested, but does not exist" );
64        }
65
66        return new $className( $context, $page, $ids );
67    }
68
69    /**
70     * Reload the list data from the primary DB.
71     */
72    public function reloadFromPrimary() {
73        $dbw = MediaWikiServices::getInstance()->getConnectionProvider()->getPrimaryDatabase();
74        $this->res = $this->doQuery( $dbw );
75    }
76
77    /**
78     * Add/remove change tags from all the items in the list.
79     *
80     * @param string[] $tagsToAdd
81     * @param string[] $tagsToRemove
82     * @param string|null $params
83     * @param string $reason
84     * @param Authority $performer
85     * @return Status
86     */
87    abstract public function updateChangeTagsOnAll(
88        array $tagsToAdd,
89        array $tagsToRemove,
90        ?string $params,
91        string $reason,
92        Authority $performer
93    );
94}