Merge "Make addedwatchtext less verbose"
[lhc/web/wiklou.git] / includes / changetags / ChangeTagsLogList.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 * Stores a list of taggable log entries.
24 * @since 1.25
25 */
26 class ChangeTagsLogList extends ChangeTagsList {
27 public function getType() {
28 return 'logentry';
29 }
30
31 /**
32 * @param DatabaseBase $db
33 * @return mixed
34 */
35 public function doQuery( $db ) {
36 $ids = array_map( 'intval', $this->ids );
37 $queryInfo = DatabaseLogEntry::getSelectQueryData();
38 $queryInfo['conds'] += array( 'log_id' => $ids );
39 $queryInfo['options'] += array( 'ORDER BY' => 'log_id DESC' );
40 ChangeTags::modifyDisplayQuery(
41 $queryInfo['tables'],
42 $queryInfo['fields'],
43 $queryInfo['conds'],
44 $queryInfo['join_conds'],
45 $queryInfo['options']
46 );
47 return $db->select(
48 $queryInfo['tables'],
49 $queryInfo['fields'],
50 $queryInfo['conds'],
51 __METHOD__,
52 $queryInfo['options'],
53 $queryInfo['join_conds']
54 );
55 }
56
57 public function newItem( $row ) {
58 return new ChangeTagsLogItem( $this, $row );
59 }
60
61 /**
62 * Add/remove change tags from all the log entries in the list.
63 *
64 * @param array $tagsToAdd
65 * @param array $tagsToRemove
66 * @param array $params
67 * @param string $reason
68 * @param User $user
69 * @return Status
70 */
71 public function updateChangeTagsOnAll( $tagsToAdd, $tagsToRemove, $params,
72 $reason, $user ) {
73
74 // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
75 for ( $this->reset(); $this->current(); $this->next() ) {
76 // @codingStandardsIgnoreEnd
77 $item = $this->current();
78 $status = ChangeTags::updateTagsWithChecks( $tagsToAdd, $tagsToRemove,
79 null, null, $item->getId(), $params, $reason, $user );
80 // Should only fail on second and subsequent times if the user trips
81 // the rate limiter
82 if ( !$status->isOK() ) {
83 break;
84 }
85 }
86
87 return $status;
88 }
89 }