コード例 #1
0
 public function testSubPageRedirect()
 {
     $ctx = new RequestContext();
     SpecialPageFactory::executePath(Title::newFromText('Special:Search/foo_bar'), $ctx);
     $url = $ctx->getOutput()->getRedirect();
     // some older versions of hhvm have a bug that doesn't parse relative
     // urls with a port, so help it out a little bit.
     // https://github.com/facebook/hhvm/issues/7136
     $url = wfExpandUrl($url, PROTO_CURRENT);
     $parts = parse_url($url);
     $this->assertEquals('/w/index.php', $parts['path']);
     parse_str($parts['query'], $query);
     $this->assertEquals('Special:Search', $query['title']);
     $this->assertEquals('foo bar', $query['search']);
 }
コード例 #2
0
ファイル: Wiki.php プロジェクト: mangowi/mediawiki
 /**
  * Performs the request.
  * - bad titles
  * - read restriction
  * - local interwiki redirects
  * - redirect loop
  * - special pages
  * - normal pages
  *
  * @throws MWException|PermissionsError|BadTitleError|HttpError
  * @return void
  */
 private function performRequest()
 {
     global $wgServer, $wgUsePathInfo, $wgTitle;
     wfProfileIn(__METHOD__);
     $request = $this->context->getRequest();
     $requestTitle = $title = $this->context->getTitle();
     $output = $this->context->getOutput();
     $user = $this->context->getUser();
     if ($request->getVal('printable') === 'yes') {
         $output->setPrintable();
     }
     $unused = null;
     // To pass it by reference
     wfRunHooks('BeforeInitialize', array(&$title, &$unused, &$output, &$user, $request, $this));
     // Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
     if (is_null($title) || $title->getDBkey() == '' && $title->getInterwiki() == '' || $title->isSpecial('Badtitle')) {
         $this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
         wfProfileOut(__METHOD__);
         throw new BadTitleError();
     }
     // Check user's permissions to read this page.
     // We have to check here to catch special pages etc.
     // We will check again in Article::view().
     $permErrors = $title->getUserPermissionsErrors('read', $user);
     if (count($permErrors)) {
         // Bug 32276: allowing the skin to generate output with $wgTitle or
         // $this->context->title set to the input title would allow anonymous users to
         // determine whether a page exists, potentially leaking private data. In fact, the
         // curid and oldid request  parameters would allow page titles to be enumerated even
         // when they are not guessable. So we reset the title to Special:Badtitle before the
         // permissions error is displayed.
         //
         // The skin mostly uses $this->context->getTitle() these days, but some extensions
         // still use $wgTitle.
         $badTitle = SpecialPage::getTitleFor('Badtitle');
         $this->context->setTitle($badTitle);
         $wgTitle = $badTitle;
         wfProfileOut(__METHOD__);
         throw new PermissionsError('read', $permErrors);
     }
     $pageView = false;
     // was an article or special page viewed?
     // Interwiki redirects
     if ($title->getInterwiki() != '') {
         $rdfrom = $request->getVal('rdfrom');
         if ($rdfrom) {
             $url = $title->getFullURL(array('rdfrom' => $rdfrom));
         } else {
             $query = $request->getValues();
             unset($query['title']);
             $url = $title->getFullURL($query);
         }
         // Check for a redirect loop
         if (!preg_match('/^' . preg_quote($wgServer, '/') . '/', $url) && $title->isLocal()) {
             // 301 so google et al report the target as the actual url.
             $output->redirect($url, 301);
         } else {
             $this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
             wfProfileOut(__METHOD__);
             throw new BadTitleError();
         }
         // Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant
     } elseif ($request->getVal('action', 'view') == 'view' && !$request->wasPosted() && ($request->getVal('title') === null || $title->getPrefixedDBkey() != $request->getVal('title')) && !count($request->getValueNames(array('action', 'title'))) && wfRunHooks('TestCanonicalRedirect', array($request, $title, $output))) {
         if ($title->isSpecialPage()) {
             list($name, $subpage) = SpecialPageFactory::resolveAlias($title->getDBkey());
             if ($name) {
                 $title = SpecialPage::getTitleFor($name, $subpage);
             }
         }
         $targetUrl = wfExpandUrl($title->getFullURL(), PROTO_CURRENT);
         // Redirect to canonical url, make it a 301 to allow caching
         if ($targetUrl == $request->getFullRequestURL()) {
             $message = "Redirect loop detected!\n\n" . "This means the wiki got confused about what page was " . "requested; this sometimes happens when moving a wiki " . "to a new server or changing the server configuration.\n\n";
             if ($wgUsePathInfo) {
                 $message .= "The wiki is trying to interpret the page " . "title from the URL path portion (PATH_INFO), which " . "sometimes fails depending on the web server. Try " . "setting \"\$wgUsePathInfo = false;\" in your " . "LocalSettings.php, or check that \$wgArticlePath " . "is correct.";
             } else {
                 $message .= "Your web server was detected as possibly not " . "supporting URL path components (PATH_INFO) correctly; " . "check your LocalSettings.php for a customized " . "\$wgArticlePath setting and/or toggle \$wgUsePathInfo " . "to true.";
             }
             throw new HttpError(500, $message);
         } else {
             $output->setSquidMaxage(1200);
             $output->redirect($targetUrl, '301');
         }
         // Special pages
     } elseif (NS_SPECIAL == $title->getNamespace()) {
         $pageView = true;
         // Actions that need to be made when we have a special pages
         SpecialPageFactory::executePath($title, $this->context);
     } else {
         // ...otherwise treat it as an article view. The article
         // may be a redirect to another article or URL.
         $article = $this->initializeArticle();
         if (is_object($article)) {
             $pageView = true;
             /**
              * $wgArticle is deprecated, do not use it.
              * @deprecated since 1.18
              */
             global $wgArticle;
             $wgArticle = new DeprecatedGlobal('wgArticle', $article, '1.18');
             $this->performAction($article, $requestTitle);
         } elseif (is_string($article)) {
             $output->redirect($article);
         } else {
             wfProfileOut(__METHOD__);
             throw new MWException("Shouldn't happen: MediaWiki::initializeArticle() returned neither an object nor a URL");
         }
     }
     if ($pageView) {
         // Promote user to any groups they meet the criteria for
         $user->addAutopromoteOnceGroups('onView');
     }
     wfProfileOut(__METHOD__);
 }
コード例 #3
0
ファイル: MediaWiki.php プロジェクト: paladox/mediawiki
 /**
  * Performs the request.
  * - bad titles
  * - read restriction
  * - local interwiki redirects
  * - redirect loop
  * - special pages
  * - normal pages
  *
  * @throws MWException|PermissionsError|BadTitleError|HttpError
  * @return void
  */
 private function performRequest()
 {
     global $wgTitle;
     $request = $this->context->getRequest();
     $requestTitle = $title = $this->context->getTitle();
     $output = $this->context->getOutput();
     $user = $this->context->getUser();
     if ($request->getVal('printable') === 'yes') {
         $output->setPrintable();
     }
     $unused = null;
     // To pass it by reference
     Hooks::run('BeforeInitialize', [&$title, &$unused, &$output, &$user, $request, $this]);
     // Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
     if (is_null($title) || $title->getDBkey() == '' && !$title->isExternal() || $title->isSpecial('Badtitle')) {
         $this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
         try {
             $this->parseTitle();
         } catch (MalformedTitleException $ex) {
             throw new BadTitleError($ex);
         }
         throw new BadTitleError();
     }
     // Check user's permissions to read this page.
     // We have to check here to catch special pages etc.
     // We will check again in Article::view().
     $permErrors = $title->isSpecial('RunJobs') ? [] : $title->getUserPermissionsErrors('read', $user);
     if (count($permErrors)) {
         // Bug 32276: allowing the skin to generate output with $wgTitle or
         // $this->context->title set to the input title would allow anonymous users to
         // determine whether a page exists, potentially leaking private data. In fact, the
         // curid and oldid request  parameters would allow page titles to be enumerated even
         // when they are not guessable. So we reset the title to Special:Badtitle before the
         // permissions error is displayed.
         // The skin mostly uses $this->context->getTitle() these days, but some extensions
         // still use $wgTitle.
         $badTitle = SpecialPage::getTitleFor('Badtitle');
         $this->context->setTitle($badTitle);
         $wgTitle = $badTitle;
         throw new PermissionsError('read', $permErrors);
     }
     // Interwiki redirects
     if ($title->isExternal()) {
         $rdfrom = $request->getVal('rdfrom');
         if ($rdfrom) {
             $url = $title->getFullURL(['rdfrom' => $rdfrom]);
         } else {
             $query = $request->getValues();
             unset($query['title']);
             $url = $title->getFullURL($query);
         }
         // Check for a redirect loop
         if (!preg_match('/^' . preg_quote($this->config->get('Server'), '/') . '/', $url) && $title->isLocal()) {
             // 301 so google et al report the target as the actual url.
             $output->redirect($url, 301);
         } else {
             $this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
             try {
                 $this->parseTitle();
             } catch (MalformedTitleException $ex) {
                 throw new BadTitleError($ex);
             }
             throw new BadTitleError();
         }
         // Handle any other redirects.
         // Redirect loops, titleless URL, $wgUsePathInfo URLs, and URLs with a variant
     } elseif (!$this->tryNormaliseRedirect($title)) {
         // Prevent information leak via Special:MyPage et al (T109724)
         if ($title->isSpecialPage()) {
             $specialPage = SpecialPageFactory::getPage($title->getDBkey());
             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() ?: [];
                         $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(['wgInternalRedirectTargetUrl' => $target->getFullURL($query)]);
                         $output->addModules('mediawiki.action.view.redirect');
                     }
                 }
             }
         }
         // Special pages ($title may have changed since if statement above)
         if (NS_SPECIAL == $title->getNamespace()) {
             // Actions that need to be made when we have a special pages
             SpecialPageFactory::executePath($title, $this->context);
         } else {
             // ...otherwise treat it as an article view. The article
             // may still be a wikipage redirect to another article or URL.
             $article = $this->initializeArticle();
             if (is_object($article)) {
                 $this->performAction($article, $requestTitle);
             } elseif (is_string($article)) {
                 $output->redirect($article);
             } else {
                 throw new MWException("Shouldn't happen: MediaWiki::initializeArticle()" . " returned neither an object nor a URL");
             }
         }
     }
 }
コード例 #4
0
ファイル: MediaWiki.php プロジェクト: nanasess/mediawiki
 /**
  * Performs the request.
  * - bad titles
  * - read restriction
  * - local interwiki redirects
  * - redirect loop
  * - special pages
  * - normal pages
  *
  * @throws MWException|PermissionsError|BadTitleError|HttpError
  * @return void
  */
 private function performRequest()
 {
     global $wgTitle;
     $request = $this->context->getRequest();
     $requestTitle = $title = $this->context->getTitle();
     $output = $this->context->getOutput();
     $user = $this->context->getUser();
     if ($request->getVal('printable') === 'yes') {
         $output->setPrintable();
     }
     $unused = null;
     // To pass it by reference
     Hooks::run('BeforeInitialize', array(&$title, &$unused, &$output, &$user, $request, $this));
     // Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
     if (is_null($title) || $title->getDBkey() == '' && !$title->isExternal() || $title->isSpecial('Badtitle')) {
         $this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
         try {
             $this->parseTitle();
         } catch (MalformedTitleException $ex) {
             throw new BadTitleError($ex);
         }
         throw new BadTitleError();
     }
     // Check user's permissions to read this page.
     // We have to check here to catch special pages etc.
     // We will check again in Article::view().
     $permErrors = $title->isSpecial('RunJobs') ? array() : $title->getUserPermissionsErrors('read', $user);
     if (count($permErrors)) {
         // Bug 32276: allowing the skin to generate output with $wgTitle or
         // $this->context->title set to the input title would allow anonymous users to
         // determine whether a page exists, potentially leaking private data. In fact, the
         // curid and oldid request  parameters would allow page titles to be enumerated even
         // when they are not guessable. So we reset the title to Special:Badtitle before the
         // permissions error is displayed.
         //
         // The skin mostly uses $this->context->getTitle() these days, but some extensions
         // still use $wgTitle.
         $badTitle = SpecialPage::getTitleFor('Badtitle');
         $this->context->setTitle($badTitle);
         $wgTitle = $badTitle;
         throw new PermissionsError('read', $permErrors);
     }
     // Interwiki redirects
     if ($title->isExternal()) {
         $rdfrom = $request->getVal('rdfrom');
         if ($rdfrom) {
             $url = $title->getFullURL(array('rdfrom' => $rdfrom));
         } else {
             $query = $request->getValues();
             unset($query['title']);
             $url = $title->getFullURL($query);
         }
         // Check for a redirect loop
         if (!preg_match('/^' . preg_quote($this->config->get('Server'), '/') . '/', $url) && $title->isLocal()) {
             // 301 so google et al report the target as the actual url.
             $output->redirect($url, 301);
         } else {
             $this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
             try {
                 $this->parseTitle();
             } catch (MalformedTitleException $ex) {
                 throw new BadTitleError($ex);
             }
             throw new BadTitleError();
         }
         // Handle any other redirects.
         // Redirect loops, titleless URL, $wgUsePathInfo URLs, and URLs with a variant
     } elseif (!$this->tryNormaliseRedirect($title)) {
         // Special pages
         if (NS_SPECIAL == $title->getNamespace()) {
             // Actions that need to be made when we have a special pages
             SpecialPageFactory::executePath($title, $this->context);
         } else {
             // ...otherwise treat it as an article view. The article
             // may still be a wikipage redirect to another article or URL.
             $article = $this->initializeArticle();
             if (is_object($article)) {
                 $this->performAction($article, $requestTitle);
             } elseif (is_string($article)) {
                 $output->redirect($article);
             } else {
                 throw new MWException("Shouldn't happen: MediaWiki::initializeArticle()" . " returned neither an object nor a URL");
             }
         }
     }
 }
コード例 #5
0
ファイル: SpecialPage.php プロジェクト: seedbank/old-repo
 /**
  * Execute a special page path.
  * The path may contain parameters, e.g. Special:Name/Params
  * Extracts the special page name and call the execute method, passing the parameters
  *
  * Returns a title object if the page is redirected, false if there was no such special
  * page, and true if it was successful.
  *
  * @param $title          Title object
  * @param $context        IContextSource
  * @param $including      Bool output is being captured for use in {{special:whatever}}
  * @return Bool
  * @deprecated since 1.18 call SpecialPageFactory method directly
  */
 public static function executePath(&$title, IContextSource &$context, $including = false)
 {
     wfDeprecated(__METHOD__, '1.18');
     return SpecialPageFactory::executePath($title, $context, $including);
 }
コード例 #6
0
ファイル: SpecialPage.php プロジェクト: eFFemeer/seizamcore
 /**
  * Execute a special page path.
  * The path may contain parameters, e.g. Special:Name/Params
  * Extracts the special page name and call the execute method, passing the parameters
  *
  * Returns a title object if the page is redirected, false if there was no such special
  * page, and true if it was successful.
  *
  * @param $title          Title object
  * @param $context        IContextSource
  * @param $including      Bool output is being captured for use in {{special:whatever}}
  * @return Bool
  * @deprecated since 1.18 call SpecialPageFactory method directly
  */
 public static function executePath(&$title, IContextSource &$context, $including = false)
 {
     return SpecialPageFactory::executePath($title, $context, $including);
 }
コード例 #7
0
ファイル: Wiki.php プロジェクト: namrenni/mediawiki
 /**
  * Performs the request.
  * - bad titles
  * - read restriction
  * - local interwiki redirects
  * - redirect loop
  * - special pages
  * - normal pages
  *
  * @return void
  */
 private function performRequest()
 {
     global $wgServer, $wgUsePathInfo;
     wfProfileIn(__METHOD__);
     $request = $this->context->getRequest();
     $title = $this->context->getTitle();
     $output = $this->context->getOutput();
     $user = $this->context->getUser();
     if ($request->getVal('printable') === 'yes') {
         $output->setPrintable();
     }
     $pageView = false;
     // was an article or special page viewed?
     wfRunHooks('BeforeInitialize', array(&$title, null, &$output, &$user, $request, $this));
     // Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
     if (is_null($title) || $title->getDBkey() == '' && $title->getInterwiki() == '' || $title->isSpecial('Badtitle')) {
         $this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
         // Die now before we mess up $wgArticle and the skin stops working
         throw new ErrorPageError('badtitle', 'badtitletext');
         // If the user is not logged in, the Namespace:title of the article must be in
         // the Read array in order for the user to see it. (We have to check here to
         // catch special pages etc. We check again in Article::view())
     } elseif (!$title->userCanRead()) {
         $output->loginToUse();
         // Interwiki redirects
     } elseif ($title->getInterwiki() != '') {
         $rdfrom = $request->getVal('rdfrom');
         if ($rdfrom) {
             $url = $title->getFullURL('rdfrom=' . urlencode($rdfrom));
         } else {
             $query = $request->getValues();
             unset($query['title']);
             $url = $title->getFullURL($query);
         }
         // Check for a redirect loop
         if (!preg_match('/^' . preg_quote($wgServer, '/') . '/', $url) && $title->isLocal()) {
             // 301 so google et al report the target as the actual url.
             $output->redirect($url, 301);
         } else {
             $this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
             wfProfileOut(__METHOD__);
             throw new ErrorPageError('badtitle', 'badtitletext');
         }
         // Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant
     } elseif ($request->getVal('action', 'view') == 'view' && !$request->wasPosted() && ($request->getVal('title') === null || $title->getPrefixedDBKey() != $request->getVal('title')) && !count($request->getValueNames(array('action', 'title'))) && wfRunHooks('TestCanonicalRedirect', array($request, $title, $output))) {
         if ($title->getNamespace() == NS_SPECIAL) {
             list($name, $subpage) = SpecialPageFactory::resolveAlias($title->getDBkey());
             if ($name) {
                 $title = SpecialPage::getTitleFor($name, $subpage);
             }
         }
         $targetUrl = wfExpandUrl($title->getFullURL(), PROTO_CURRENT);
         // Redirect to canonical url, make it a 301 to allow caching
         if ($targetUrl == $request->getFullRequestURL()) {
             $message = "Redirect loop detected!\n\n" . "This means the wiki got confused about what page was " . "requested; this sometimes happens when moving a wiki " . "to a new server or changing the server configuration.\n\n";
             if ($wgUsePathInfo) {
                 $message .= "The wiki is trying to interpret the page " . "title from the URL path portion (PATH_INFO), which " . "sometimes fails depending on the web server. Try " . "setting \"\$wgUsePathInfo = false;\" in your " . "LocalSettings.php, or check that \$wgArticlePath " . "is correct.";
             } else {
                 $message .= "Your web server was detected as possibly not " . "supporting URL path components (PATH_INFO) correctly; " . "check your LocalSettings.php for a customized " . "\$wgArticlePath setting and/or toggle \$wgUsePathInfo " . "to true.";
             }
             wfHttpError(500, "Internal error", $message);
         } else {
             $output->setSquidMaxage(1200);
             $output->redirect($targetUrl, '301');
         }
         // Special pages
     } elseif (NS_SPECIAL == $title->getNamespace()) {
         $pageView = true;
         // Actions that need to be made when we have a special pages
         SpecialPageFactory::executePath($title, $this->context);
     } else {
         // ...otherwise treat it as an article view. The article
         // may be a redirect to another article or URL.
         $article = $this->initializeArticle();
         if (is_object($article)) {
             $pageView = true;
             /**
              * $wgArticle is deprecated, do not use it. This will possibly be removed
              * entirely in 1.20 or 1.21
              * @deprecated since 1.18
              */
             global $wgArticle;
             $wgArticle = $article;
             $this->performAction($article);
         } elseif (is_string($article)) {
             $output->redirect($article);
         } else {
             wfProfileOut(__METHOD__);
             throw new MWException("Shouldn't happen: MediaWiki::initializeArticle() returned neither an object nor a URL");
         }
     }
     if ($pageView) {
         // Promote user to any groups they meet the criteria for
         $user->addAutopromoteOnceGroups('onView');
     }
     wfProfileOut(__METHOD__);
 }
コード例 #8
0
 /**
  * Performs the request.
  * - bad titles
  * - read restriction
  * - local interwiki redirects
  * - redirect loop
  * - special pages
  * - normal pages
  *
  * @throws MWException|PermissionsError|BadTitleError|HttpError
  * @return void
  */
 private function performRequest()
 {
     global $wgTitle;
     $request = $this->context->getRequest();
     $requestTitle = $title = $this->context->getTitle();
     $output = $this->context->getOutput();
     $user = $this->context->getUser();
     ### <SANDSTORM>
     global $wgAuth;
     $name = array_key_exists('HTTP_X_SANDSTORM_USERNAME', $_SERVER) ? $_SERVER['HTTP_X_SANDSTORM_USERNAME'] : '******';
     $name = urldecode($name);
     $original_name = $name;
     $id = array_key_exists('HTTP_X_SANDSTORM_USER_ID', $_SERVER) ? $_SERVER['HTTP_X_SANDSTORM_USER_ID'] : '';
     $count = 2;
     $isNew = false;
     if ($user->isAnon()) {
         $u = null;
         do {
             $u = User::newFromName($name, 'creatable');
             // TODO
             if (!is_object($u)) {
                 wfLogWarning('no name for ' . $name);
                 throw new BadTitleError();
             }
             if (0 != $u->idForName() && $u->getEmail() !== $id && !empty($id)) {
                 $name = $original_name . $count;
             }
             $count++;
         } while (0 != $u->idForName() && $u->getEmail() !== $id && !empty($id));
         if (0 == $u->idForName()) {
             $permissions = array_key_exists('HTTP_X_SANDSTORM_PERMISSIONS', $_SERVER) ? $_SERVER['HTTP_X_SANDSTORM_PERMISSIONS'] : '';
             $pass = sha1(mt_rand());
             $u->setRealName($name);
             $u->setEmail($id);
             if (!$wgAuth->addUser($u, $pass, "", $name)) {
                 // TODO
                 wfLogWarning('externaldberror');
             }
             $this->initUser($u, $pass, false);
             if (strpos($permissions, 'admin') !== false) {
                 wfLogWarning('setting user as admin: ' . $name);
                 $u->addGroup('sysop');
                 $u->addGroup('bureaucrat');
                 $u->saveSettings();
             }
             if (!empty($id)) {
                 $u->addGroup('editor');
                 $u->saveSettings();
             }
             $isNew = true;
         }
         // wfSetupSession();
         // Not sure why, but I manually have to set session cookie
         setcookie(session_name(), MWCryptRand::generateHex(32), 0, '/');
         $u->setCookies();
         wfResetSessionID();
         $this->context->setUser($u);
         $user = $this->context->getUser();
         $wgUser = $u;
     }
     if ($isNew) {
         wfRunHooks('AddNewAccount', array($u, false));
         $u->addNewUserLogEntry('create');
         $injected_html = '';
         wfRunHooks('UserLoginComplete', array(&$u, &$injected_html));
         $welcome_creation_msg = 'welcomecreation-msg';
         wfRunHooks('BeforeWelcomeCreation', array(&$welcome_creation_msg, &$injected_html));
     } else {
         $injected_html = '';
         wfRunHooks('UserLoginComplete', array(&$u, &$injected_html));
     }
     # </SANDSTORM>
     if ($request->getVal('printable') === 'yes') {
         $output->setPrintable();
     }
     $unused = null;
     // To pass it by reference
     Hooks::run('BeforeInitialize', array(&$title, &$unused, &$output, &$user, $request, $this));
     // Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
     if (is_null($title) || $title->getDBkey() == '' && !$title->isExternal() || $title->isSpecial('Badtitle')) {
         $this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
         throw new BadTitleError();
     }
     // Check user's permissions to read this page.
     // We have to check here to catch special pages etc.
     // We will check again in Article::view().
     $permErrors = $title->isSpecial('RunJobs') ? array() : $title->getUserPermissionsErrors('read', $user);
     if (count($permErrors)) {
         // Bug 32276: allowing the skin to generate output with $wgTitle or
         // $this->context->title set to the input title would allow anonymous users to
         // determine whether a page exists, potentially leaking private data. In fact, the
         // curid and oldid request  parameters would allow page titles to be enumerated even
         // when they are not guessable. So we reset the title to Special:Badtitle before the
         // permissions error is displayed.
         //
         // The skin mostly uses $this->context->getTitle() these days, but some extensions
         // still use $wgTitle.
         $badTitle = SpecialPage::getTitleFor('Badtitle');
         $this->context->setTitle($badTitle);
         $wgTitle = $badTitle;
         throw new PermissionsError('read', $permErrors);
     }
     // Interwiki redirects
     if ($title->isExternal()) {
         $rdfrom = $request->getVal('rdfrom');
         if ($rdfrom) {
             $url = $title->getFullURL(array('rdfrom' => $rdfrom));
         } else {
             $query = $request->getValues();
             unset($query['title']);
             $url = $title->getFullURL($query);
         }
         // Check for a redirect loop
         if (!preg_match('/^' . preg_quote($this->config->get('Server'), '/') . '/', $url) && $title->isLocal()) {
             // 301 so google et al report the target as the actual url.
             $output->redirect($url, 301);
         } else {
             $this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
             throw new BadTitleError();
         }
         // Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant
     } elseif ($request->getVal('action', 'view') == 'view' && !$request->wasPosted() && ($request->getVal('title') === null || $title->getPrefixedDBkey() != $request->getVal('title')) && !count($request->getValueNames(array('action', 'title'))) && Hooks::run('TestCanonicalRedirect', array($request, $title, $output))) {
         if ($title->isSpecialPage()) {
             list($name, $subpage) = SpecialPageFactory::resolveAlias($title->getDBkey());
             if ($name) {
                 $title = SpecialPage::getTitleFor($name, $subpage);
             }
         }
         $targetUrl = wfExpandUrl($title->getFullURL(), PROTO_CURRENT);
         // Redirect to canonical url, make it a 301 to allow caching
         if ($targetUrl == $request->getFullRequestURL()) {
             $message = "Redirect loop detected!\n\n" . "This means the wiki got confused about what page was " . "requested; this sometimes happens when moving a wiki " . "to a new server or changing the server configuration.\n\n";
             if ($this->config->get('UsePathInfo')) {
                 $message .= "The wiki is trying to interpret the page " . "title from the URL path portion (PATH_INFO), which " . "sometimes fails depending on the web server. Try " . "setting \"\$wgUsePathInfo = false;\" in your " . "LocalSettings.php, or check that \$wgArticlePath " . "is correct.";
             } else {
                 $message .= "Your web server was detected as possibly not " . "supporting URL path components (PATH_INFO) correctly; " . "check your LocalSettings.php for a customized " . "\$wgArticlePath setting and/or toggle \$wgUsePathInfo " . "to true.";
             }
             throw new HttpError(500, $message);
         } else {
             $output->setSquidMaxage(1200);
             $output->redirect($targetUrl, '301');
         }
         // Special pages
     } elseif (NS_SPECIAL == $title->getNamespace()) {
         // Actions that need to be made when we have a special pages
         SpecialPageFactory::executePath($title, $this->context);
     } else {
         // ...otherwise treat it as an article view. The article
         // may be a redirect to another article or URL.
         $article = $this->initializeArticle();
         if (is_object($article)) {
             $this->performAction($article, $requestTitle);
         } elseif (is_string($article)) {
             $output->redirect($article);
         } else {
             throw new MWException("Shouldn't happen: MediaWiki::initializeArticle()" . " returned neither an object nor a URL");
         }
     }
 }