Fix AbstractBlock param types in documentation
[lhc/web/wiklou.git] / includes / api / ApiBase.php
index 19d84f7..7cb2dbf 100644 (file)
@@ -20,6 +20,8 @@
  * @file
  */
 
+use MediaWiki\Block\AbstractBlock;
+use MediaWiki\MediaWikiServices;
 use Wikimedia\Rdbms\IDatabase;
 
 /**
@@ -1198,7 +1200,8 @@ abstract class ApiBase extends ContextSource {
                        $provided = $this->getMain()->getCheck( $encParamName );
 
                        if ( isset( $value ) && $type == 'namespace' ) {
-                               $type = MWNamespace::getValidNamespaces();
+                               $type = MediaWikiServices::getInstance()->getNamespaceInfo()->
+                                       getValidNamespaces();
                                if ( isset( $paramSettings[self::PARAM_EXTRA_NAMESPACES] ) &&
                                        is_array( $paramSettings[self::PARAM_EXTRA_NAMESPACES] )
                                ) {
@@ -1813,7 +1816,7 @@ abstract class ApiBase extends ContextSource {
                        if ( is_string( $error[0] ) && isset( self::$blockMsgMap[$error[0]] ) && $user->getBlock() ) {
                                list( $msg, $code ) = self::$blockMsgMap[$error[0]];
                                $status->fatal( ApiMessage::create( $msg, $code,
-                                       [ 'blockinfo' => $this->getBlockInfo( $user->getBlock() ) ]
+                                       [ 'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
                                ) );
                        } else {
                                $status->fatal( ...$error );
@@ -1836,7 +1839,7 @@ abstract class ApiBase extends ContextSource {
                foreach ( self::$blockMsgMap as $msg => list( $apiMsg, $code ) ) {
                        if ( $status->hasMessage( $msg ) && $user->getBlock() ) {
                                $status->replaceMessage( $msg, ApiMessage::create( $apiMsg, $code,
-                                       [ 'blockinfo' => $this->getBlockInfo( $user->getBlock() ) ]
+                                       [ 'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
                                ) );
                        }
                }
@@ -2026,28 +2029,28 @@ abstract class ApiBase extends ContextSource {
         * error handler and die with an error message including block info.
         *
         * @since 1.27
-        * @param Block $block The block used to generate the ApiUsageException
+        * @param AbstractBlock $block The block used to generate the ApiUsageException
         * @throws ApiUsageException always
         */
-       public function dieBlocked( Block $block ) {
+       public function dieBlocked( AbstractBlock $block ) {
                // Die using the appropriate message depending on block type
                if ( $block->getType() == Block::TYPE_AUTO ) {
                        $this->dieWithError(
                                'apierror-autoblocked',
                                'autoblocked',
-                               [ 'blockinfo' => $this->getBlockInfo( $block ) ]
+                               [ 'blockinfo' => $this->getBlockDetails( $block ) ]
                        );
                } elseif ( !$block->isSitewide() ) {
                        $this->dieWithError(
                                'apierror-blocked-partial',
                                'blocked',
-                               [ 'blockinfo' => $this->getBlockInfo( $block ) ]
+                               [ 'blockinfo' => $this->getBlockDetails( $block ) ]
                        );
                } else {
                        $this->dieWithError(
                                'apierror-blocked',
                                'blocked',
-                               [ 'blockinfo' => $this->getBlockInfo( $block ) ]
+                               [ 'blockinfo' => $this->getBlockDetails( $block ) ]
                        );
                }
        }
@@ -2682,24 +2685,6 @@ abstract class ApiBase extends ContextSource {
                ] ];
        }
 
-       /**
-        * Truncate an array to a certain length.
-        * @deprecated since 1.32, no replacement
-        * @param array &$arr Array to truncate
-        * @param int $limit Maximum length
-        * @return bool True if the array was truncated, false otherwise
-        */
-       public static function truncateArray( &$arr, $limit ) {
-               wfDeprecated( __METHOD__, '1.32' );
-               $modified = false;
-               while ( count( $arr ) > $limit ) {
-                       array_pop( $arr );
-                       $modified = true;
-               }
-
-               return $modified;
-       }
-
        /**@}*/
 }