Make PageImages default API license parameter configurable

Bug: T156190
Change-Id: Id4b43f2597d5a063dca0d46f308b6283620e9974
This commit is contained in:
aude 2017-05-20 16:29:31 +02:00
parent 88329411c7
commit 97572615e0
3 changed files with 13 additions and 1 deletions

View file

@ -88,6 +88,10 @@
"@doc": "Temporary feature flag - Whether page images should be restricted to those in section id 0.",
"@fixme": "Please remove a month after it has defaulted to true on the cluster (T152115)",
"value": true
},
"PageImagesAPIDefaultLicense": {
"@doc": "Get images with either a 'free' license or 'any' (including free and non-free) license by default, via 'pilicense' option, in pageprops query api. The value of this setting should be either 'free' or 'any'.",
"value": "free"
}
},
"manifest_version": 2

View file

@ -264,7 +264,7 @@ class ApiQueryPageImages extends ApiQueryBase {
'license' => [
ApiBase::PARAM_TYPE => [ self::PARAM_LICENSE_FREE, self::PARAM_LICENSE_ANY ],
ApiBase::PARAM_ISMULTI => false,
ApiBase::PARAM_DFLT => self::PARAM_LICENSE_FREE,
ApiBase::PARAM_DFLT => $this->getConfig()->get( 'PageImagesAPIDefaultLicense' ),
],
'continue' => [
ApiBase::PARAM_TYPE => 'integer',

View file

@ -59,10 +59,18 @@ class ApiQueryPageImagesProxy extends ApiQueryPageImages {
class ApiQueryPageImagesTest extends PHPUnit_Framework_TestCase {
private function newInstance() {
$config = new \HashConfig( [
'PageImagesAPIDefaultLicense' => 'free'
]);
$context = $this->getMockBuilder( 'IContextSource' )
->disableOriginalConstructor()
->getMock();
$context->expects( $this->any() )
->method( 'getConfig' )
->willReturn( $config );
$main = $this->getMockBuilder( 'ApiMain' )
->disableOriginalConstructor()
->getMock();