Merge "Added a separate error message for mkdir failures"
[lhc/web/wiklou.git] / includes / changetags / ChangeTagsRevisionList.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 revisions.
26 * @since 1.25
27 */
28 class ChangeTagsRevisionList extends ChangeTagsList {
29 public function getType() {
30 return 'revision';
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 = [
40 'tables' => [ 'revision', 'user' ],
41 'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ),
42 'conds' => [
43 'rev_page' => $this->title->getArticleID(),
44 'rev_id' => $ids,
45 ],
46 'options' => [ 'ORDER BY' => 'rev_id DESC' ],
47 'join_conds' => [
48 'page' => Revision::pageJoinCond(),
49 'user' => Revision::userJoinCond(),
50 ],
51 ];
52 ChangeTags::modifyDisplayQuery(
53 $queryInfo['tables'],
54 $queryInfo['fields'],
55 $queryInfo['conds'],
56 $queryInfo['join_conds'],
57 $queryInfo['options'],
58 ''
59 );
60 return $db->select(
61 $queryInfo['tables'],
62 $queryInfo['fields'],
63 $queryInfo['conds'],
64 __METHOD__,
65 $queryInfo['options'],
66 $queryInfo['join_conds']
67 );
68 }
69
70 public function newItem( $row ) {
71 return new ChangeTagsRevisionItem( $this, $row );
72 }
73
74 /**
75 * Add/remove change tags from all the revisions in the list.
76 *
77 * @param array $tagsToAdd
78 * @param array $tagsToRemove
79 * @param array $params
80 * @param string $reason
81 * @param User $user
82 * @return Status
83 */
84 public function updateChangeTagsOnAll( $tagsToAdd, $tagsToRemove, $params, $reason, $user ) {
85 // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
86 for ( $this->reset(); $this->current(); $this->next() ) {
87 // @codingStandardsIgnoreEnd
88 $item = $this->current();
89 $status = ChangeTags::updateTagsWithChecks( $tagsToAdd, $tagsToRemove,
90 null, $item->getId(), null, $params, $reason, $user );
91 // Should only fail on second and subsequent times if the user trips
92 // the rate limiter
93 if ( !$status->isOK() ) {
94 break;
95 }
96 }
97
98 return $status;
99 }
100 }