Merge "ApiBlock: Avoid PHP warning when partial blocks are enabled but not used"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 19 Dec 2018 20:20:47 +0000 (20:20 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 19 Dec 2018 20:20:47 +0000 (20:20 +0000)
includes/api/ApiBlock.php
tests/phpunit/includes/api/ApiBlockTest.php

index 8976626..ed3d01c 100644 (file)
@@ -61,7 +61,7 @@ class ApiBlock extends ApiBase {
                                $editingRestriction = 'partial';
                        }
 
-                       $pageRestrictions = implode( "\n", $params['pagerestrictions'] );
+                       $pageRestrictions = implode( "\n", (array)$params['pagerestrictions'] );
                }
 
                if ( $params['userid'] !== null ) {
index e229f0c..feafdef 100644 (file)
@@ -215,6 +215,19 @@ class ApiBlockTest extends ApiTestCase {
                $this->doBlock( [ 'expiry' => '' ] );
        }
 
+       public function testBlockWithoutRestrictions() {
+               $this->setMwGlobals( [
+                       'wgEnablePartialBlocks' => true,
+               ] );
+
+               $this->doBlock();
+
+               $block = Block::newFromTarget( $this->mUser->getName() );
+
+               $this->assertTrue( $block->isSitewide() );
+               $this->assertCount( 0, $block->getRestrictions() );
+       }
+
        public function testBlockWithRestrictions() {
                $this->setMwGlobals( [
                        'wgEnablePartialBlocks' => true,