Merge "Remove gen from RawAction."
[lhc/web/wiklou.git] / includes / api / ApiRollback.php
index 02e62a0..7037fb6 100644 (file)
@@ -40,6 +40,8 @@ class ApiRollback extends ApiBase {
        private $mUser = null;
 
        public function execute() {
+               $this->useTransactionalTimeLimit();
+
                $user = $this->getUser();
                $params = $this->extractRequestParams();
 
@@ -57,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,
@@ -79,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() ),
@@ -105,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