Merge "Document that services don't normally vary by global state"
[lhc/web/wiklou.git] / includes / api / ApiQueryBlocks.php
index 8aff2aa..f9da9a3 100644 (file)
@@ -21,7 +21,7 @@
  */
 
 use Wikimedia\Rdbms\IResultWrapper;
-use MediaWiki\Block\BlockRestriction;
+use MediaWiki\MediaWikiServices;
 
 /**
  * Query module to enumerate all user blocks
@@ -176,7 +176,7 @@ class ApiQueryBlocks extends ApiQueryBase {
                        $this->addWhereIf( 'ipb_range_end > ipb_range_start', isset( $show['range'] ) );
                }
 
-               if ( !$this->getUser()->isAllowed( 'hideuser' ) ) {
+               if ( !$this->getPermissionManager()->userHasRight( $this->getUser(), 'hideuser' ) ) {
                        $this->addWhereFld( 'ipb_deleted', 0 );
                }
 
@@ -292,7 +292,8 @@ class ApiQueryBlocks extends ApiQueryBase {
                        }
                }
 
-               $restrictions = BlockRestriction::loadByBlockId( $partialIds );
+               $blockRestrictionStore = MediaWikiServices::getInstance()->getBlockRestrictionStore();
+               $restrictions = $blockRestrictionStore->loadByBlockId( $partialIds );
 
                $data = [];
                $keys = [
@@ -304,6 +305,8 @@ class ApiQueryBlocks extends ApiQueryBase {
                        $id = $restriction->getBlockId();
                        switch ( $restriction->getType() ) {
                                case 'page':
+                                       /** @var \MediaWiki\Block\Restriction\PageRestriction $restriction */
+                                       '@phan-var \MediaWiki\Block\Restriction\PageRestriction $restriction';
                                        $value = [ 'id' => $restriction->getValue() ];
                                        if ( $restriction->getTitle() ) {
                                                self::addTitleInfo( $value, $restriction->getTitle() );