jenkins-bot has submitted this change and it was merged.

Change subject: API: Fix parameter validation in setnotificationtimestamp
......................................................................


API: Fix parameter validation in setnotificationtimestamp

This was broken in I7a3d7b6e, when the ApiPageSet parameters stopped
being returned by getAllowedParams() and so by extractRequestParams().
Although it would be broken differently if they had been.

Change-Id: I4b6ec21fd7b7c932856546df1ccad574d996db1f
---
M includes/api/ApiPageSet.php
M includes/api/ApiSetNotificationTimestamp.php
2 files changed, 27 insertions(+), 2 deletions(-)

Approvals:
  Yurik: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php
index bab59b7..074efe4 100644
--- a/includes/api/ApiPageSet.php
+++ b/includes/api/ApiPageSet.php
@@ -218,6 +218,30 @@
        }
 
        /**
+        * 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()
         * @param string $fieldName Field name
diff --git a/includes/api/ApiSetNotificationTimestamp.php 
b/includes/api/ApiSetNotificationTimestamp.php
index b40476a..58d5d9a 100644
--- a/includes/api/ApiSetNotificationTimestamp.php
+++ b/includes/api/ApiSetNotificationTimestamp.php
@@ -44,8 +44,9 @@
                $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' );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/54011
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4b6ec21fd7b7c932856546df1ccad574d996db1f
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Yurik <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to