Set API limits for page restrictions to 10
authorThalia <thalia.e.chan@googlemail.com>
Mon, 17 Dec 2018 17:53:27 +0000 (17:53 +0000)
committerThalia <thalia.e.chan@googlemail.com>
Mon, 17 Dec 2018 17:53:27 +0000 (17:53 +0000)
Bug: T212142
Change-Id: Ide0f2f86df2101194155be53a4b9012ddefbbcaf

includes/api/ApiBlock.php
tests/phpunit/includes/api/ApiBlockTest.php

index 3581ac8..8976626 100644 (file)
@@ -57,20 +57,6 @@ class ApiBlock extends ApiBase {
                $editingRestriction = 'sitewide';
                $pageRestrictions = '';
                if ( $this->getConfig()->get( 'EnablePartialBlocks' ) ) {
-                       if ( $params['pagerestrictions'] ) {
-                               $count = count( $params['pagerestrictions'] );
-                               if ( $count > 10 ) {
-                                       $this->dieWithError(
-                                               $this->msg(
-                                                       'apierror-integeroutofrange-abovebotmax',
-                                                       'pagerestrictions',
-                                                       10,
-                                                       $count
-                                               )
-                                       );
-                               }
-                       }
-
                        if ( $params['partial'] ) {
                                $editingRestriction = 'partial';
                        }
@@ -207,6 +193,8 @@ class ApiBlock extends ApiBase {
                        $params['partial'] = false;
                        $params['pagerestrictions'] = [
                                ApiBase::PARAM_ISMULTI => true,
+                               ApiBase::PARAM_ISMULTI_LIMIT1 => 10,
+                               ApiBase::PARAM_ISMULTI_LIMIT2 => 10,
                        ];
                }
 
index 9898e53..e229f0c 100644 (file)
@@ -274,7 +274,8 @@ class ApiBlockTest extends ApiTestCase {
 
        /**
         * @expectedException ApiUsageException
-        * @expectedExceptionMessage "pagerestrictions" may not be over 10 (set to 11) for bots or sysops.
+        * @expectedExceptionMessage Too many values supplied for parameter "pagerestrictions". The
+        * limit is 10.
         */
        public function testBlockingToManyRestrictions() {
                $this->setMwGlobals( [