Add tag parameter to API action=rollback
authormhutti1 <mhutti1@gmail.com>
Tue, 15 Dec 2015 23:45:37 +0000 (00:45 +0100)
committermhutti1 <mhutti1@gmail.com>
Wed, 16 Dec 2015 15:52:53 +0000 (16:52 +0100)
Added code to allow tag change in ApiRollback.php

Bug: T111948
Change-Id: Ic8dcefe569f169041c9e0078a49af4ee87d2bbd6

includes/api/ApiRollback.php

index 6a3346f..7037fb6 100644 (file)
@@ -59,6 +59,16 @@ class ApiRollback extends ApiBase {
                $pageObj = WikiPage::factory( $titleObj );
                $summary = $params['summary'];
                $details = array();
+
+               // If change tagging was requested, check that the user is allowed to tag,
+               // and the tags are valid
+               if ( count( $params['tags'] ) ) {
+                       $tagStatus = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $user );
+                       if ( !$tagStatus->isOK() ) {
+                               $this->dieStatus( $tagStatus );
+                       }
+               }
+
                $retval = $pageObj->doRollback(
                        $this->getRbUser( $params ),
                        $summary,
@@ -81,6 +91,10 @@ class ApiRollback extends ApiBase {
                // Watch pages
                $this->setWatch( $watch, $titleObj, 'watchrollback' );
 
+               if ( count( $params['tags'] ) ) {
+                       ChangeTags::addTags( $params['tags'], null, intval( $details['newid'] ), null, null );
+               }
+
                $info = array(
                        'title' => $titleObj->getPrefixedText(),
                        'pageid' => intval( $details['current']->getPage() ),
@@ -107,6 +121,10 @@ class ApiRollback extends ApiBase {
                        'pageid' => array(
                                ApiBase::PARAM_TYPE => 'integer'
                        ),
+                       'tags' => array(
+                               ApiBase::PARAM_TYPE => ChangeTags::listExplicitlyDefinedTags(),
+                               ApiBase::PARAM_ISMULTI => true,
+                       ),
                        'user' => array(
                                ApiBase::PARAM_TYPE => 'string',
                                ApiBase::PARAM_REQUIRED => true