Merge "Migrate BagOStuff::incr() calls to incrWithInit()"
[lhc/web/wiklou.git] / includes / specials / SpecialRedirect.php
index 49f1b3c..50867dd 100644 (file)
@@ -21,6 +21,8 @@
  * @ingroup SpecialPage
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * A special page that redirects to: the user for a numeric user id,
  * the file for a given filename, or the page for a given revision id.
@@ -81,6 +83,11 @@ class SpecialRedirect extends FormSpecialPage {
                        // Message: redirect-not-exists
                        return Status::newFatal( $this->getMessagePrefix() . '-not-exists' );
                }
+               if ( $user->isHidden() && !MediaWikiServices::getInstance()->getPermissionManager()
+                       ->userHasRight( $this->getUser(), 'hideuser' )
+               ) {
+                       throw new PermissionsError( null, [ 'badaccess-group0' ] );
+               }
                $userpage = Title::makeTitle( NS_USER, $username );
 
                return Status::newGood( $userpage->getFullURL( '', false, PROTO_CURRENT ) );
@@ -101,7 +108,7 @@ class SpecialRedirect extends FormSpecialPage {
                } catch ( MalformedTitleException $e ) {
                        return Status::newFatal( $e->getMessageObject() );
                }
-               $file = wfFindFile( $title );
+               $file = MediaWikiServices::getInstance()->getRepoGroup()->findFile( $title );
 
                if ( !$file || !$file->exists() ) {
                        // Message: redirect-not-exists