Set context on RedirectSpecialPage in MediaWiki.php
authorumherirrender <umherirrender_de.wp@web.de>
Tue, 2 Feb 2016 19:56:25 +0000 (20:56 +0100)
committerumherirrender <umherirrender_de.wp@web.de>
Thu, 4 Feb 2016 19:14:03 +0000 (20:14 +0100)
Special page instance from SpecialPageFactory::getPage needs a context
set, to avoid using RequestContext::getMain in SpecialPage::getContext

Change-Id: I6e0828c6c9668c4ef10a729533190a5225b8782f

includes/MediaWiki.php

index 7846ca4..4939c4d 100644 (file)
@@ -247,29 +247,31 @@ class MediaWiki {
                        // Prevent information leak via Special:MyPage et al (T109724)
                        if ( $title->isSpecialPage() ) {
                                $specialPage = SpecialPageFactory::getPage( $title->getDBKey() );
-                               if ( $specialPage instanceof RedirectSpecialPage
-                                       && $this->config->get( 'HideIdentifiableRedirects' )
-                                       && $specialPage->personallyIdentifiableTarget()
-                               ) {
-                                       list( , $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBKey() );
-                                       $target = $specialPage->getRedirect( $subpage );
-                                       // target can also be true. We let that case fall through to normal processing.
-                                       if ( $target instanceof Title ) {
-                                               $query = $specialPage->getRedirectQuery() ?: array();
-                                               $request = new DerivativeRequest( $this->context->getRequest(), $query );
-                                               $request->setRequestURL( $this->context->getRequest()->getRequestURL() );
-                                               $this->context->setRequest( $request );
-                                               // Do not varnish cache these. May vary even for anons
-                                               $this->context->getOutput()->lowerCdnMaxage( 0 );
-                                               $this->context->setTitle( $target );
-                                               $wgTitle = $target;
-                                               // Reset action type cache. (Special pages have only view)
-                                               $this->action = null;
-                                               $title = $target;
-                                               $output->addJsConfigVars( array(
-                                                       'wgInternalRedirectTargetUrl' => $target->getFullURL( $query ),
-                                               ) );
-                                               $output->addModules( 'mediawiki.action.view.redirect' );
+                               if ( $specialPage instanceof RedirectSpecialPage ) {
+                                       $specialPage->setContext( $this->context );
+                                       if ( $this->config->get( 'HideIdentifiableRedirects' )
+                                               && $specialPage->personallyIdentifiableTarget()
+                                       ) {
+                                               list( , $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBKey() );
+                                               $target = $specialPage->getRedirect( $subpage );
+                                               // target can also be true. We let that case fall through to normal processing.
+                                               if ( $target instanceof Title ) {
+                                                       $query = $specialPage->getRedirectQuery() ?: array();
+                                                       $request = new DerivativeRequest( $this->context->getRequest(), $query );
+                                                       $request->setRequestURL( $this->context->getRequest()->getRequestURL() );
+                                                       $this->context->setRequest( $request );
+                                                       // Do not varnish cache these. May vary even for anons
+                                                       $this->context->getOutput()->lowerCdnMaxage( 0 );
+                                                       $this->context->setTitle( $target );
+                                                       $wgTitle = $target;
+                                                       // Reset action type cache. (Special pages have only view)
+                                                       $this->action = null;
+                                                       $title = $target;
+                                                       $output->addJsConfigVars( array(
+                                                               'wgInternalRedirectTargetUrl' => $target->getFullURL( $query ),
+                                                       ) );
+                                                       $output->addModules( 'mediawiki.action.view.redirect' );
+                                               }
                                        }
                                }
                        }