Add string length limits
authorGergő Tisza <gtisza@wikimedia.org>
Sun, 12 Nov 2017 09:51:34 +0000 (09:51 +0000)
committerGergő Tisza <gtisza@wikimedia.org>
Tue, 21 Nov 2017 10:24:11 +0000 (10:24 +0000)
commit17d001b73a3bd291e0f77794fa60fa5495609d68
tree2fd097ad826bae12ad81f2a44eb35cbd1257d58c
parenteb136047fff3440bd46748a24dcca2972f9f53cb
Add string length limits

Adds two new ApiBase::getAllowedParams() keys:
PARAM_MAX_BYTES and PARAM_MAX_CHARS, to set a length
limit for a (string-like) parameter.

This makes it easy to document and enforce database
field length limits (where relying on the database
would either result in unfriendly error messages or
silent truncation, depending on DB settings) and
also exposes them in structured form so API clients
can verify the length without doing roundtrips.

Change-Id: I2e784972d7e11cad79fdef887bbcde297dbd9ce0
includes/api/ApiBase.php
includes/api/ApiHelp.php
includes/api/ApiParamInfo.php
includes/api/i18n/en.json
includes/api/i18n/qqq.json
tests/phpunit/structure/ApiStructureTest.php