Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
72.73% |
8 / 11 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| ChangeTagsList | |
80.00% |
8 / 10 |
|
66.67% |
2 / 3 |
3.07 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| factory | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| reloadFromPrimary | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| updateChangeTagsOnAll | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * @file |
| 5 | */ |
| 6 | |
| 7 | namespace MediaWiki\ChangeTags; |
| 8 | |
| 9 | use InvalidArgumentException; |
| 10 | use MediaWiki\Context\IContextSource; |
| 11 | use MediaWiki\MediaWikiServices; |
| 12 | use MediaWiki\Page\PageIdentity; |
| 13 | use MediaWiki\Permissions\Authority; |
| 14 | use MediaWiki\RevisionList\RevisionListBase; |
| 15 | use MediaWiki\Status\Status; |
| 16 | |
| 17 | /** |
| 18 | * Generic list for change tagging. |
| 19 | * |
| 20 | * @ingroup ChangeTags |
| 21 | * @property ChangeTagsLogItem $current |
| 22 | * @method ChangeTagsLogItem next() |
| 23 | * @method ChangeTagsLogItem reset() |
| 24 | * @method ChangeTagsLogItem current() |
| 25 | */ |
| 26 | abstract class ChangeTagsList extends RevisionListBase { |
| 27 | public function __construct( IContextSource $context, PageIdentity $page, array $ids ) { |
| 28 | parent::__construct( $context, $page ); |
| 29 | $this->ids = $ids; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Create a ChangeTagsList instance of the given type. |
| 34 | * |
| 35 | * @param string $typeName 'revision' or 'logentry' |
| 36 | * @param IContextSource $context |
| 37 | * @param PageIdentity $page |
| 38 | * @param array $ids |
| 39 | * @return ChangeTagsList An instance of the requested subclass |
| 40 | * @throws InvalidArgumentException If you give an unknown $typeName |
| 41 | */ |
| 42 | public static function factory( $typeName, IContextSource $context, |
| 43 | PageIdentity $page, array $ids |
| 44 | ) { |
| 45 | $className = match ( $typeName ) { |
| 46 | 'revision' => ChangeTagsRevisionList::class, |
| 47 | 'logentry' => ChangeTagsLogList::class, |
| 48 | default => throw new InvalidArgumentException( "Class $typeName requested, but does not exist" ) |
| 49 | }; |
| 50 | return new $className( $context, $page, $ids ); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Reload the list data from the primary DB. |
| 55 | */ |
| 56 | public function reloadFromPrimary() { |
| 57 | $dbw = MediaWikiServices::getInstance()->getConnectionProvider()->getPrimaryDatabase(); |
| 58 | $this->res = $this->doQuery( $dbw ); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Add/remove change tags from all the items in the list. |
| 63 | * |
| 64 | * @param string[] $tagsToAdd |
| 65 | * @param string[] $tagsToRemove |
| 66 | * @param string|null $params |
| 67 | * @param string $reason |
| 68 | * @param Authority $performer |
| 69 | * @return Status |
| 70 | */ |
| 71 | abstract public function updateChangeTagsOnAll( |
| 72 | array $tagsToAdd, |
| 73 | array $tagsToRemove, |
| 74 | ?string $params, |
| 75 | string $reason, |
| 76 | Authority $performer |
| 77 | ); |
| 78 | } |
| 79 | |
| 80 | /** @deprecated class alias since 1.44 */ |
| 81 | class_alias( ChangeTagsList::class, 'ChangeTagsList' ); |