Fix usage of ApiBase::PARAM_* deprecated constants

The ones that are replaced with ParamValidator

Bug: T275455
Change-Id: Ie88e576d3a6dc61155f2b7f49e86a993c2577427
This commit is contained in:
gerritbot 2022-04-04 01:28:52 +02:00 committed by Ladsgroup
parent c2ee690bdd
commit d0f26549f2
2 changed files with 20 additions and 19 deletions

View file

@ -7,6 +7,7 @@ use ApiQuery;
use ApiQueryBase;
use MediaWiki\MediaWikiServices;
use Title;
use Wikimedia\ParamValidator\ParamValidator;
use Wikimedia\ParamValidator\TypeDef\IntegerDef;
/**
@ -225,33 +226,33 @@ class ApiQueryPageImages extends ApiQueryBase {
public function getAllowedParams() {
return [
'prop' => [
ApiBase::PARAM_TYPE => [ 'thumbnail', 'name', 'original' ],
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_DFLT => 'thumbnail|name',
ParamValidator::PARAM_TYPE => [ 'thumbnail', 'name', 'original' ],
ParamValidator::PARAM_ISMULTI => true,
ParamValidator::PARAM_DEFAULT => 'thumbnail|name',
],
'thumbsize' => [
ApiBase::PARAM_TYPE => 'integer',
ApiBase::PARAM_DFLT => 50,
ParamValidator::PARAM_TYPE => 'integer',
ParamValidator::PARAM_DEFAULT => 50,
],
'limit' => [
ApiBase::PARAM_DFLT => 50,
ApiBase::PARAM_TYPE => 'limit',
ParamValidator::PARAM_DEFAULT => 50,
ParamValidator::PARAM_TYPE => 'limit',
IntegerDef::PARAM_MIN => 1,
IntegerDef::PARAM_MAX => 50,
IntegerDef::PARAM_MAX2 => 100,
],
'license' => [
ApiBase::PARAM_TYPE => [ PageImages::LICENSE_FREE, PageImages::LICENSE_ANY ],
ApiBase::PARAM_ISMULTI => false,
ApiBase::PARAM_DFLT => $this->getConfig()->get( 'PageImagesAPIDefaultLicense' ),
ParamValidator::PARAM_TYPE => [ PageImages::LICENSE_FREE, PageImages::LICENSE_ANY ],
ParamValidator::PARAM_ISMULTI => false,
ParamValidator::PARAM_DEFAULT => $this->getConfig()->get( 'PageImagesAPIDefaultLicense' ),
],
'continue' => [
ApiBase::PARAM_TYPE => 'integer',
ParamValidator::PARAM_TYPE => 'integer',
ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
],
'langcode' => [
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_DFLT => null
ParamValidator::PARAM_TYPE => 'string',
ParamValidator::PARAM_DEFAULT => null
]
];
}

View file

@ -2,11 +2,11 @@
namespace PageImages\Tests;
use ApiBase;
use PageImages\ApiQueryPageImages;
use PageImages\PageImages;
use PHPUnit\Framework\TestCase;
use Title;
use Wikimedia\ParamValidator\ParamValidator;
use Wikimedia\ParamValidator\TypeDef\IntegerDef;
use Wikimedia\Rdbms\FakeResultWrapper;
use Wikimedia\TestingAccessWrapper;
@ -67,15 +67,15 @@ class ApiQueryPageImagesTest extends TestCase {
$this->assertNotEmpty( $params );
$this->assertContainsOnly( 'array', $params );
$this->assertArrayHasKey( 'limit', $params );
$this->assertSame( 50, $params['limit'][ApiBase::PARAM_DFLT] );
$this->assertSame( 'limit', $params['limit'][ApiBase::PARAM_TYPE] );
$this->assertSame( 50, $params['limit'][ParamValidator::PARAM_DEFAULT] );
$this->assertSame( 'limit', $params['limit'][ParamValidator::PARAM_TYPE] );
$this->assertSame( 1, $params['limit'][IntegerDef::PARAM_MIN] );
$this->assertSame( 50, $params['limit'][IntegerDef::PARAM_MAX] );
$this->assertSame( 100, $params['limit'][IntegerDef::PARAM_MAX2] );
$this->assertArrayHasKey( 'license', $params );
$this->assertSame( [ 'free', 'any' ], $params['license'][ApiBase::PARAM_TYPE] );
$this->assertSame( 'free', $params['license'][ApiBase::PARAM_DFLT] );
$this->assertFalse( $params['license'][ApiBase::PARAM_ISMULTI] );
$this->assertSame( [ 'free', 'any' ], $params['license'][ParamValidator::PARAM_TYPE] );
$this->assertSame( 'free', $params['license'][ParamValidator::PARAM_DEFAULT] );
$this->assertFalse( $params['license'][ParamValidator::PARAM_ISMULTI] );
}
/**