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