Merge "Make DBAccessBase use DBConnRef, rename $wiki, and hide getLoadBalancer()"
[lhc/web/wiklou.git] / includes / changetags / ChangeTagsList.php
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 /**
23 * Generic list for change tagging.
24 *
25 * @property ChangeTagsLogItem $current
26 * @method ChangeTagsLogItem next()
27 * @method ChangeTagsLogItem reset()
28 * @method ChangeTagsLogItem current()
29 * @phan-file-suppress PhanParamSignatureMismatch
30 */
31 abstract class ChangeTagsList extends RevisionListBase {
32 function __construct( IContextSource $context, Title $title, array $ids ) {
33 parent::__construct( $context, $title );
34 $this->ids = $ids;
35 }
36
37 /**
38 * Creates a ChangeTags*List of the requested type.
39 *
40 * @param string $typeName 'revision' or 'logentry'
41 * @param IContextSource $context
42 * @param Title $title
43 * @param array $ids
44 * @return ChangeTagsList An instance of the requested subclass
45 * @throws Exception If you give an unknown $typeName
46 */
47 public static function factory( $typeName, IContextSource $context,
48 Title $title, array $ids
49 ) {
50 switch ( $typeName ) {
51 case 'revision':
52 $className = ChangeTagsRevisionList::class;
53 break;
54 case 'logentry':
55 $className = ChangeTagsLogList::class;
56 break;
57 default:
58 throw new Exception( "Class $typeName requested, but does not exist" );
59 }
60
61 return new $className( $context, $title, $ids );
62 }
63
64 /**
65 * Reload the list data from the master DB.
66 */
67 function reloadFromMaster() {
68 $dbw = wfGetDB( DB_MASTER );
69 $this->res = $this->doQuery( $dbw );
70 }
71
72 /**
73 * Add/remove change tags from all the items in the list.
74 *
75 * @param array $tagsToAdd
76 * @param array $tagsToRemove
77 * @param string|null $params
78 * @param string $reason
79 * @param User $user
80 * @return Status
81 */
82 abstract function updateChangeTagsOnAll( $tagsToAdd, $tagsToRemove, $params,
83 $reason, $user );
84 }