Only show notoken as possible API error once
authorMarius Hoch <hoo@online.de>
Sun, 9 Jun 2013 01:14:15 +0000 (03:14 +0200)
committerHoo man <hoo@online.de>
Tue, 11 Jun 2013 00:03:46 +0000 (00:03 +0000)
Currently notoken is being listed as possible
API error twice if it's explicitly set as
required parameter and needsToken() returns
true.

See:
https://www.wikidata.org/w/api.php?action=paraminfo&modules=edit

Change-Id: Ia17c5cfa634919b43affa146df0d1dc0ff06b758

includes/api/ApiBase.php

index fdf3b76..57287d7 100644 (file)
@@ -1597,7 +1597,12 @@ abstract class ApiBase extends ContextSource {
                }
 
                if ( $this->needsToken() ) {
-                       $ret[] = array( 'missingparam', 'token' );
+                       if ( !isset( $params['token'][ApiBase::PARAM_REQUIRED] )
+                               || !$params['token'][ApiBase::PARAM_REQUIRED]
+                       ) {
+                               // Add token as possible missing parameter, if not already done
+                               $ret[] = array( 'missingparam', 'token' );
+                       }
                        $ret[] = array( 'sessionfailure' );
                }