X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/includes/changetags/ChangeTagsRevisionList.php diff --git a/includes/changetags/ChangeTagsRevisionList.php b/includes/changetags/ChangeTagsRevisionList.php new file mode 100644 index 00000000..91193b0e --- /dev/null +++ b/includes/changetags/ChangeTagsRevisionList.php @@ -0,0 +1,100 @@ +ids ); + $queryInfo = [ + 'tables' => [ 'revision', 'user' ], + 'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ), + 'conds' => [ + 'rev_page' => $this->title->getArticleID(), + 'rev_id' => $ids, + ], + 'options' => [ 'ORDER BY' => 'rev_id DESC' ], + 'join_conds' => [ + 'page' => Revision::pageJoinCond(), + 'user' => Revision::userJoinCond(), + ], + ]; + ChangeTags::modifyDisplayQuery( + $queryInfo['tables'], + $queryInfo['fields'], + $queryInfo['conds'], + $queryInfo['join_conds'], + $queryInfo['options'], + '' + ); + return $db->select( + $queryInfo['tables'], + $queryInfo['fields'], + $queryInfo['conds'], + __METHOD__, + $queryInfo['options'], + $queryInfo['join_conds'] + ); + } + + public function newItem( $row ) { + return new ChangeTagsRevisionItem( $this, $row ); + } + + /** + * Add/remove change tags from all the revisions in the list. + * + * @param array $tagsToAdd + * @param array $tagsToRemove + * @param array $params + * @param string $reason + * @param User $user + * @return Status + */ + public function updateChangeTagsOnAll( $tagsToAdd, $tagsToRemove, $params, $reason, $user ) { + // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed + for ( $this->reset(); $this->current(); $this->next() ) { + // @codingStandardsIgnoreEnd + $item = $this->current(); + $status = ChangeTags::updateTagsWithChecks( $tagsToAdd, $tagsToRemove, + null, $item->getId(), null, $params, $reason, $user ); + // Should only fail on second and subsequent times if the user trips + // the rate limiter + if ( !$status->isOK() ) { + break; + } + } + + return $status; + } +}