Replace some usages of &$this in hook parameters
[lhc/web/wiklou.git] / includes / api / ApiBase.php
index 65fcb99..063d661 100644 (file)
@@ -1627,6 +1627,12 @@ abstract class ApiBase extends ContextSource {
                                        'autoblocked',
                                        [ 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $user->getBlock() ) ]
                                ) );
+                       } elseif ( is_array( $error ) && $error[0] === 'systemblockedtext' && $user->getBlock() ) {
+                               $status->fatal( ApiMessage::create(
+                                       'apierror-systemblocked',
+                                       'blocked',
+                                       [ 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $user->getBlock() ) ]
+                               ) );
                        } else {
                                call_user_func_array( [ $status, 'fatal' ], (array)$error );
                        }
@@ -1930,7 +1936,10 @@ abstract class ApiBase extends ContextSource {
         */
        public function getFinalDescription() {
                $desc = $this->getDescription();
-               Hooks::run( 'APIGetDescription', [ &$this, &$desc ] );
+
+               // Avoid PHP 7.1 warning of passing $this by reference
+               $apiModule = $this;
+               Hooks::run( 'APIGetDescription', [ &$apiModule, &$desc ] );
                $desc = self::escapeWikiText( $desc );
                if ( is_array( $desc ) ) {
                        $desc = implode( "\n", $desc );
@@ -1978,7 +1987,9 @@ abstract class ApiBase extends ContextSource {
                        ] + ( isset( $params['token'] ) ? $params['token'] : [] );
                }
 
-               Hooks::run( 'APIGetAllowedParams', [ &$this, &$params, $flags ] );
+               // Avoid PHP 7.1 warning of passing $this by reference
+               $apiModule = $this;
+               Hooks::run( 'APIGetAllowedParams', [ &$apiModule, &$params, $flags ] );
 
                return $params;
        }
@@ -1996,7 +2007,10 @@ abstract class ApiBase extends ContextSource {
                $path = $this->getModulePath();
 
                $desc = $this->getParamDescription();
-               Hooks::run( 'APIGetParamDescription', [ &$this, &$desc ] );
+
+               // Avoid PHP 7.1 warning of passing $this by reference
+               $apiModule = $this;
+               Hooks::run( 'APIGetParamDescription', [ &$apiModule, &$desc ] );
 
                if ( !$desc ) {
                        $desc = [];
@@ -2243,7 +2257,7 @@ abstract class ApiBase extends ContextSource {
         * "apihelp-{$this->getModulePath()}-description".
         *
         * @deprecated since 1.25
-        * @return Message|string|array
+        * @return Message|string|array|false
         */
        protected function getDescription() {
                return false;
@@ -2464,6 +2478,7 @@ abstract class ApiBase extends ContextSource {
                'confirmedittext' => 'confirmedittext',
                'blockedtext' => 'apierror-blocked',
                'autoblockedtext' => 'apierror-autoblocked',
+               'systemblockedtext' => 'apierror-systemblocked',
                'actionthrottledtext' => 'apierror-ratelimited',
                'alreadyrolled' => 'alreadyrolled',
                'cantrollback' => 'cantrollback',