Merge "API: Fix parameter validation in setnotificationtimestamp"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 21 Mar 2013 18:10:43 +0000 (18:10 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 21 Mar 2013 18:10:43 +0000 (18:10 +0000)
includes/api/ApiPageSet.php
includes/api/ApiSetNotificationTimestamp.php

index bab59b7..074efe4 100644 (file)
@@ -217,6 +217,30 @@ class ApiPageSet extends ApiBase {
                return $this->mResolveRedirects;
        }
 
+       /**
+        * Return the parameter name that is the source of data for this PageSet
+        *
+        * If multiple source parameters are specified (e.g. titles and pageids),
+        * one will be named arbitrarily.
+        *
+        * @return string|null
+        */
+       public function getDataSource() {
+               if ( $this->mAllowGenerator && isset( $this->mParams['generator'] ) ) {
+                       return 'generator';
+               }
+               if ( isset( $this->mParams['titles'] ) ) {
+                       return 'titles';
+               }
+               if ( isset( $this->mParams['pageids'] ) ) {
+                       return 'pageids';
+               }
+               if ( isset( $this->mParams['revids'] ) ) {
+                       return 'revids';
+               }
+               return null;
+       }
+
        /**
         * Request an additional field from the page table.
         * Must be called before execute()
index b40476a..58d5d9a 100644 (file)
@@ -44,8 +44,9 @@ class ApiSetNotificationTimestamp extends ApiBase {
                $this->requireMaxOneParameter( $params, 'timestamp', 'torevid', 'newerthanrevid' );
 
                $pageSet = $this->getPageSet();
-               $args = array_merge( array( $params, 'entirewatchlist' ), array_keys( $pageSet->getAllowedParams() ) );
-               call_user_func_array( array( $this, 'requireOnlyOneParameter' ), $args );
+               if ( $params['entirewatchlist'] && $pageSet->getDataSource() !== null ) {
+                       $this->dieUsage( "Cannot use 'entirewatchlist' at the same time as '{$pageSet->getDataSource()}'", 'multisource' );
+               }
 
                $dbw = wfGetDB( DB_MASTER, 'api' );