API: Log when too many values are passed for a multi-valued parameter
authorBrad Jorsch <bjorsch@wikimedia.org>
Wed, 24 Aug 2016 16:10:05 +0000 (12:10 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Wed, 24 Aug 2016 16:16:30 +0000 (12:16 -0400)
Currently the API just throws away the excess values, no continuation.
This is probably not the best behavior. There is a warning, but clients
are notorious for just ignoring warnings.

We could improve the situation:
* Turn it into an error.
* Turn it into an error for most cases, but allow some to override if
  necessary.
* Allow some cases to make it an error, while keeping it a warning by
  default.

Before we can decide which option to pick, we should get an idea of how
often this is being hit and which things it's being hit for.

Bug: T41936
Change-Id: I52926f410c30d1cd7e7fcd86465b16519fb5cbd2

includes/api/ApiBase.php

index fcb748c..66c1b53 100644 (file)
@@ -1171,6 +1171,7 @@ abstract class ApiBase extends ContextSource {
                        : self::LIMIT_SML1;
 
                if ( self::truncateArray( $valuesList, $sizeLimit ) ) {
+                       $this->logFeatureUsage( "too-many-$valueName-for-{$this->getModulePath()}" );
                        $this->setWarning( "Too many values supplied for parameter '$valueName': " .
                                "the limit is $sizeLimit" );
                }