Create preference to watchlist pages after rollbacking
[lhc/web/wiklou.git] / includes / api / ApiRollback.php
index fbe87d2..1bba715 100644 (file)
@@ -61,7 +61,13 @@ class ApiRollback extends ApiBase {
                        $this->dieUsageMsg( reset( $retval ) );
                }
 
-               $this->setWatch( $params['watchlist'], $titleObj );
+               $watch = 'preferences';
+               if ( isset( $params['watchlist'] ) ) {
+                       $watch = $params['watchlist'];
+               }
+
+               // Watch pages
+               $this->setWatch( $watch, $titleObj, 'watchrollback' );
 
                $info = array(
                        'title' => $titleObj->getPrefixedText(),
@@ -115,8 +121,8 @@ class ApiRollback extends ApiBase {
                $p = $this->getModulePrefix();
 
                return array(
-                       'title' => "Title of the page you want to delete. Cannot be used together with {$p}pageid",
-                       'pageid' => "Page ID of the page you want to delete. Cannot be used together with {$p}title",
+                       'title' => "Title of the page you want to roll back. Cannot be used together with {$p}pageid",
+                       'pageid' => "Page ID of the page you want to roll back. Cannot be used together with {$p}title",
                        'user' => 'Name of the user whose edits are to be rolled back. If ' .
                                'set incorrectly, you\'ll get a badtoken error.',
                        'token' => 'A rollback token previously retrieved through ' .
@@ -149,12 +155,16 @@ class ApiRollback extends ApiBase {
        }
 
        public function getPossibleErrors() {
-               return array_merge( parent::getPossibleErrors(), array(
-                       array( 'invalidtitle', 'title' ),
-                       array( 'notanarticle' ),
-                       array( 'nosuchpageid', 'pageid' ),
-                       array( 'invaliduser', 'user' ),
-               ) );
+               return array_merge(
+                       parent::getPossibleErrors(),
+                       $this->getRequireOnlyOneParameterErrorMessages( array( 'title', 'pageid' ) ),
+                       array(
+                               array( 'invalidtitle', 'title' ),
+                               array( 'notanarticle' ),
+                               array( 'nosuchpageid', 'pageid' ),
+                               array( 'invaliduser', 'user' ),
+                       )
+               );
        }
 
        public function needsToken() {