aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/api/query/ApiQueryTest.php
diff options
context:
space:
mode:
authorFomafix <fomafix@googlemail.com>2018-01-21 21:58:59 +0100
committerFomafix <fomafix@googlemail.com>2018-01-28 19:05:07 +0100
commitb8f97035cefbe63f2cb8ce1aa2f2d47f57c008c9 (patch)
treee7c74461a4f8abd497f6862df2fec930d8b796e6 /tests/phpunit/includes/api/query/ApiQueryTest.php
parentaf431ec783e66c12d6693d638029a9f912c14541 (diff)
downloadmediawikicore-b8f97035cefbe63f2cb8ce1aa2f2d47f57c008c9.tar.gz
mediawikicore-b8f97035cefbe63f2cb8ce1aa2f2d47f57c008c9.zip
API: Allow to pass whitespaces in MultiValue
This allows to response with an invalidreason instead silently ignore the parameter. Example request: api.php?format=json&action=query&titles=%20 Response before this change: { "batchcomplete": "" } Response with this change: { "batchcomplete": "", "query": { "pages": { "-1": { "title": " ", "invalidreason": "The requested page title is empty or contains only the name of a namespace.", "invalid": "" } } } } Bug: T185846 Change-Id: I6fdaf32792a0e6e37b08176f975c10607093351b
Diffstat (limited to 'tests/phpunit/includes/api/query/ApiQueryTest.php')
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryTest.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/phpunit/includes/api/query/ApiQueryTest.php b/tests/phpunit/includes/api/query/ApiQueryTest.php
index 8026e5444eae..88a2e62f4618 100644
--- a/tests/phpunit/includes/api/query/ApiQueryTest.php
+++ b/tests/phpunit/includes/api/query/ApiQueryTest.php
@@ -81,6 +81,19 @@ class ApiQueryTest extends ApiTestCase {
$this->assertArrayHasKey( 'invalid', $data[0]['query']['pages'][-1] );
}
+ public function testTitlesWithWhitespaces() {
+ $data = $this->doApiRequest( [
+ 'action' => 'query',
+ 'titles' => ' '
+ ] );
+
+ $this->assertArrayHasKey( 'query', $data[0] );
+ $this->assertArrayHasKey( 'pages', $data[0]['query'] );
+ $this->assertEquals( 1, count( $data[0]['query']['pages'] ) );
+ $this->assertArrayHasKey( -1, $data[0]['query']['pages'] );
+ $this->assertArrayHasKey( 'invalid', $data[0]['query']['pages'][-1] );
+ }
+
/**
* Test the ApiBase::titlePartToKey function
*