Start better utalizing OutputPage as the focal point for things related to the output...
authorDaniel Friesen <dantman@users.mediawiki.org>
Sun, 3 Apr 2011 03:59:47 +0000 (03:59 +0000)
committerDaniel Friesen <dantman@users.mediawiki.org>
Sun, 3 Apr 2011 03:59:47 +0000 (03:59 +0000)
includes/Article.php
includes/OutputPage.php
includes/SpecialPage.php
includes/api/ApiParse.php

index 53334b5..0ae1032 100644 (file)
@@ -1580,7 +1580,7 @@ class Article {
         * Builds trackback links for article display if $wgUseTrackbacks is set to true
         */
        public function addTrackbacks() {
-               global $wgOut, $wgUser;
+               global $wgOut;
 
                $dbr = wfGetDB( DB_SLAVE );
                $tbs = $dbr->select( 'trackbacks',
@@ -1598,9 +1598,9 @@ class Article {
                foreach ( $tbs as $o ) {
                        $rmvtxt = "";
 
-                       if ( $wgUser->isAllowed( 'trackback' ) ) {
+                       if ( $wgOut->getUser()->isAllowed( 'trackback' ) ) {
                                $delurl = $this->mTitle->getFullURL( "action=deletetrackback&tbid=" .
-                                       $o->tb_id . "&token=" . urlencode( $wgUser->editToken() ) );
+                                       $o->tb_id . "&token=" . urlencode( $wgOut->getUser()->editToken() ) );
                                $rmvtxt = wfMsg( 'trackbackremove', htmlspecialchars( $delurl ) );
                        }
 
@@ -1620,15 +1620,15 @@ class Article {
         * Removes trackback record for current article from trackbacks table
         */
        public function deletetrackback() {
-               global $wgUser, $wgRequest, $wgOut;
+               global $wgRequest, $wgOut;
 
-               if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ) ) ) {
+               if ( !$wgOut->getUser()->matchEditToken( $wgRequest->getVal( 'token' ) ) ) {
                        $wgOut->addWikiMsg( 'sessionfailure' );
 
                        return;
                }
 
-               $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgUser );
+               $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgOut->getUser() );
 
                if ( count( $permission_errors ) ) {
                        $wgOut->showPermissionsErrorPage( $permission_errors );
@@ -1658,9 +1658,9 @@ class Article {
         * Handle action=purge
         */
        public function purge() {
-               global $wgUser, $wgRequest, $wgOut;
+               global $wgRequest, $wgOut;
 
-               if ( $wgUser->isAllowed( 'purge' ) || $wgRequest->wasPosted() ) {
+               if ( $wgOut->getUser()->isAllowed( 'purge' ) || $wgRequest->wasPosted() ) {
                        //FIXME: shouldn't this be in doPurge()?
                        if ( wfRunHooks( 'ArticlePurge', array( &$this ) ) ) {
                                $this->doPurge();
@@ -2273,14 +2273,14 @@ class Article {
         * Mark this particular edit/page as patrolled
         */
        public function markpatrolled() {
-               global $wgOut, $wgUser, $wgRequest;
+               global $wgOut, $wgRequest;
 
                $wgOut->setRobotPolicy( 'noindex,nofollow' );
 
                # If we haven't been given an rc_id value, we can't do anything
                $rcid = (int) $wgRequest->getVal( 'rcid' );
 
-               if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ), $rcid ) ) {
+               if ( !$wgOut->getUser()->matchEditToken( $wgRequest->getVal( 'token' ), $rcid ) ) {
                        $wgOut->showErrorPage( 'sessionfailure-title', 'sessionfailure' );
                        return;
                }
@@ -2333,9 +2333,9 @@ class Article {
         * User-interface handler for the "watch" action
         */
        public function watch() {
-               global $wgUser, $wgOut;
+               global $wgOut;
 
-               if ( $wgUser->isAnon() ) {
+               if ( $wgOut->getUser()->isAnon() ) {
                        $wgOut->showErrorPage( 'watchnologin', 'watchnologintext' );
                        return;
                }
@@ -2380,9 +2380,9 @@ class Article {
         * User interface handler for the "unwatch" action.
         */
        public function unwatch() {
-               global $wgUser, $wgOut;
+               global $wgOut;
 
-               if ( $wgUser->isAnon() ) {
+               if ( $wgOut->getUser()->isAnon() ) {
                        $wgOut->showErrorPage( 'watchnologin', 'watchnologintext' );
                        return;
                }
@@ -2742,10 +2742,10 @@ class Article {
         * UI entry point for page deletion
         */
        public function delete() {
-               global $wgUser, $wgOut, $wgRequest;
+               global $wgOut, $wgRequest;
 
                $confirm = $wgRequest->wasPosted() &&
-                               $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) );
+                               $wgOut->getUser()->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) );
 
                $this->DeleteReasonList = $wgRequest->getText( 'wpDeleteReasonList', 'other' );
                $this->DeleteReason = $wgRequest->getText( 'wpReason' );
@@ -2760,7 +2760,7 @@ class Article {
                }
 
                # Flag to hide all contents of the archived revisions
-               $suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgUser->isAllowed( 'suppressrevision' );
+               $suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgOut->getUser()->isAllowed( 'suppressrevision' );
 
                # This code desperately needs to be totally rewritten
 
@@ -2772,7 +2772,7 @@ class Article {
                }
 
                # Check permissions
-               $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgUser );
+               $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgOut->getUser() );
 
                if ( count( $permission_errors ) > 0 ) {
                        $wgOut->showPermissionsErrorPage( $permission_errors );
@@ -2818,7 +2818,7 @@ class Article {
                if ( $confirm ) {
                        $this->doDelete( $reason, $suppress );
 
-                       if ( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) {
+                       if ( $wgRequest->getCheck( 'wpWatch' ) && $wgOut->getUser()->isLoggedIn() ) {
                                $this->doWatch();
                        } elseif ( $this->mTitle->userIsWatching() ) {
                                $this->doUnwatch();
@@ -2837,7 +2837,7 @@ class Article {
                if ( $hasHistory && !$confirm ) {
                        global $wgLang;
 
-                       $skin = $wgUser->getSkin();
+                       $skin = $wgOut->getSkin();
                        $revisions = $this->estimateRevisionCount();
                        //FIXME: lego
                        $wgOut->addHTML( '<strong class="mw-delete-warning-revisions">' .
@@ -2944,18 +2944,18 @@ class Article {
         * @param $reason String: prefilled reason
         */
        public function confirmDelete( $reason ) {
-               global $wgOut, $wgUser;
+               global $wgOut;
 
                wfDebug( "Article::confirmDelete\n" );
 
-               $deleteBackLink = $wgUser->getSkin()->linkKnown( $this->mTitle );
+               $deleteBackLink = $wgOut->getSkin()->linkKnown( $this->mTitle );
                $wgOut->setSubtitle( wfMsgHtml( 'delete-backlink', $deleteBackLink ) );
                $wgOut->setRobotPolicy( 'noindex,nofollow' );
                $wgOut->addWikiMsg( 'confirmdeletetext' );
 
                wfRunHooks( 'ArticleConfirmDelete', array( $this, $wgOut, &$reason ) );
 
-               if ( $wgUser->isAllowed( 'suppressrevision' ) ) {
+               if ( $wgOut->getUser()->isAllowed( 'suppressrevision' ) ) {
                        $suppress = "<tr id=\"wpDeleteSuppressRow\">
                                        <td></td>
                                        <td class='mw-input'><strong>" .
@@ -2966,7 +2966,7 @@ class Article {
                } else {
                        $suppress = '';
                }
-               $checkWatch = $wgUser->getBoolOption( 'watchdeletion' ) || $this->mTitle->userIsWatching();
+               $checkWatch = $wgOut->getUser()->getBoolOption( 'watchdeletion' ) || $this->mTitle->userIsWatching();
 
                $form = Xml::openElement( 'form', array( 'method' => 'post',
                        'action' => $this->mTitle->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ) ) .
@@ -2999,7 +2999,7 @@ class Article {
                        </tr>";
 
                # Disallow watching if user is not logged in
-               if ( $wgUser->isLoggedIn() ) {
+               if ( $wgOut->getUser()->isLoggedIn() ) {
                        $form .= "
                        <tr>
                                <td></td>
@@ -3021,11 +3021,11 @@ class Article {
                        </tr>" .
                        Xml::closeElement( 'table' ) .
                        Xml::closeElement( 'fieldset' ) .
-                       Html::hidden( 'wpEditToken', $wgUser->editToken() ) .
+                       Html::hidden( 'wpEditToken', $wgOut->getUser()->editToken() ) .
                        Xml::closeElement( 'form' );
 
-                       if ( $wgUser->isAllowed( 'editinterface' ) ) {
-                               $skin = $wgUser->getSkin();
+                       if ( $wgOut->getUser()->isAllowed( 'editinterface' ) ) {
+                               $skin = $wgOut->getSkin();
                                $title = Title::makeTitle( NS_MEDIAWIKI, 'Deletereason-dropdown' );
                                $link = $skin->link(
                                        $title,
index cd53914..cc24ea6 100644 (file)
@@ -193,6 +193,9 @@ class OutputPage {
        /// Stores a Title object (of the current page).
        protected $mTitle = null;
 
+       /// Stores a User object (the one the page is being rendered for)
+       protected $mUser = null;
+
        /**
         * An array of stylesheet filenames (relative from skins path), with options
         * for CSS media, IE conditions, and RTL/LTR direction.
@@ -549,7 +552,7 @@ class OutputPage {
         * @return Boolean: true iff cache-ok headers was sent.
         */
        public function checkLastModified( $timestamp ) {
-               global $wgCachePages, $wgCacheEpoch, $wgUser, $wgRequest;
+               global $wgCachePages, $wgCacheEpoch, $wgRequest;
 
                if ( !$timestamp || $timestamp == '19700101000000' ) {
                        wfDebug( __METHOD__ . ": CACHE DISABLED, NO TIMESTAMP\n" );
@@ -559,7 +562,7 @@ class OutputPage {
                        wfDebug( __METHOD__ . ": CACHE DISABLED\n", false );
                        return false;
                }
-               if( $wgUser->getOption( 'nocache' ) ) {
+               if( $this->getUser()->getOption( 'nocache' ) ) {
                        wfDebug( __METHOD__ . ": USER DISABLED CACHE\n", false );
                        return false;
                }
@@ -567,7 +570,7 @@ class OutputPage {
                $timestamp = wfTimestamp( TS_MW, $timestamp );
                $modifiedTimes = array(
                        'page' => $timestamp,
-                       'user' => $wgUser->getTouched(),
+                       'user' => $this->getUser()->getTouched(),
                        'epoch' => $wgCacheEpoch
                );
                wfRunHooks( 'OutputPageCheckLastModified', array( &$modifiedTimes ) );
@@ -772,6 +775,40 @@ class OutputPage {
                }
        }
 
+       /**
+        * Set the User object to use
+        *
+        * @param $u User object
+        */
+       public function setUser( $u ) {
+               $this->mUser = $u;
+       }
+
+       /**
+        * Get the User object used in this instance
+        *
+        * @return User
+        */
+       public function getUser() {
+               if ( !isset($this->mUser) ) {
+                       wfDebug( __METHOD__ . " called and \$mUser is null. Return \$wgUser for sanity\n" );
+                       global $wgUser;
+                       return $wgUser;
+               }
+               return $this->mUser;
+       }
+
+       /**
+        * Get the Skin object used to render this instance
+        *
+        * @return Skin
+        */
+       public function getSkin() {
+               // For now we'll just proxy to the user. In the future a saner location for
+               // organizing what skin to use may be chosen
+               return $this->getUser()->getSkin();
+       }
+
        /**
         * Replace the subtile with $str
         *
@@ -1009,7 +1046,7 @@ class OutputPage {
         * @param $categories Array mapping category name => sort key
         */
        public function addCategoryLinks( $categories ) {
-               global $wgUser, $wgContLang;
+               global $wgContLang;
 
                if ( !is_array( $categories ) || count( $categories ) == 0 ) {
                        return;
@@ -1048,7 +1085,6 @@ class OutputPage {
 
                # Add the remaining categories to the skin
                if ( wfRunHooks( 'OutputPageMakeCategoryLinks', array( &$this, $categories, &$this->mCategoryLinks ) ) ) {
-                       $sk = $wgUser->getSkin();
                        foreach ( $categories as $category => $type ) {
                                $origcategory = $category;
                                $title = Title::makeTitleSafe( NS_CATEGORY, $category );
@@ -1060,7 +1096,7 @@ class OutputPage {
                                }
                                $text = $wgContLang->convertHtml( $title->getText() );
                                $this->mCategories[] = $title->getText();
-                               $this->mCategoryLinks[$type][] = $sk->link( $title, $text );
+                               $this->mCategoryLinks[$type][] = $this->getSkin()->link( $title, $text );
                        }
                }
        }
@@ -1768,7 +1804,7 @@ class OutputPage {
         * the object, let's actually output it:
         */
        public function output() {
-               global $wgUser, $wgOutputEncoding, $wgRequest;
+               global $wgOutputEncoding, $wgRequest;
                global $wgLanguageCode, $wgDebugRedirects, $wgMimeType;
 
                if( $this->mDoNothing ) {
@@ -1826,7 +1862,7 @@ class OutputPage {
                } else {
                        $this->addDefaultModules();
 
-                       $sk = $wgUser->getSkin( $this->getTitle() );
+                       $sk = $this->getSkin( $this->getTitle() );
 
                        // Hook that allows last minute changes to the output page, e.g.
                        // adding of CSS or Javascript by extensions.
@@ -1868,29 +1904,29 @@ class OutputPage {
         * @return nothing
         */
        function blockedPage( $return = true ) {
-               global $wgUser, $wgContLang, $wgLang;
+               global $wgContLang, $wgLang;
 
                $this->setPageTitle( wfMsg( 'blockedtitle' ) );
                $this->setRobotPolicy( 'noindex,nofollow' );
                $this->setArticleRelated( false );
 
-               $name = $wgUser->blockedBy();
-               $reason = $wgUser->blockedFor();
+               $name = $this->getUser()->blockedBy();
+               $reason = $this->getUser()->blockedFor();
                if( $reason == '' ) {
                        $reason = wfMsg( 'blockednoreason' );
                }
                $blockTimestamp = $wgLang->timeanddate(
-                       wfTimestamp( TS_MW, $wgUser->mBlock->mTimestamp ), true
+                       wfTimestamp( TS_MW, $this->getUser()->mBlock->mTimestamp ), true
                );
                $ip = wfGetIP();
 
                $link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]";
 
-               $blockid = $wgUser->mBlock->getId();
+               $blockid = $this->getUser()->mBlock->getId();
 
-               $blockExpiry = $wgLang->formatExpiry( $wgUser->mBlock->mExpiry );
+               $blockExpiry = $wgLang->formatExpiry( $this->getUser()->mBlock->mExpiry );
 
-               if ( $wgUser->mBlock->mAuto ) {
+               if ( $this->getUser()->mBlock->mAuto ) {
                        $msg = 'autoblockedtext';
                } else {
                        $msg = 'blockedtext';
@@ -1898,7 +1934,7 @@ class OutputPage {
 
                /* $ip returns who *is* being blocked, $intended contains who was meant to be blocked.
                 * This could be a username, an IP range, or a single IP. */
-               $intended = $wgUser->mBlock->getTarget();
+               $intended = $this->getUser()->mBlock->getTarget();
 
                $this->addWikiMsg(
                        $msg, $link, $reason, $ip, $name, $blockid, $blockExpiry,
@@ -2004,22 +2040,18 @@ class OutputPage {
         * Produce the stock "please login to use the wiki" page
         */
        public function loginToUse() {
-               global $wgUser;
-
-               if( $wgUser->isLoggedIn() ) {
+               if( $this->getUser()->isLoggedIn() ) {
                        $this->permissionRequired( 'read' );
                        return;
                }
 
-               $skin = $wgUser->getSkin();
-
                $this->setPageTitle( wfMsg( 'loginreqtitle' ) );
                $this->setHtmlTitle( wfMsg( 'errorpagetitle' ) );
                $this->setRobotPolicy( 'noindex,nofollow' );
                $this->setArticleRelated( false );
 
                $loginTitle = SpecialPage::getTitleFor( 'Userlogin' );
-               $loginLink = $skin->link(
+               $loginLink = $this->getSkin()->link(
                        $loginTitle,
                        wfMsgHtml( 'loginreqlink' ),
                        array(),
@@ -2095,9 +2127,6 @@ class OutputPage {
         * @param $action    String: action that was denied or null if unknown
         */
        public function readOnlyPage( $source = null, $protected = false, $reasons = array(), $action = null ) {
-               global $wgUser;
-               $skin = $wgUser->getSkin();
-
                $this->setRobotPolicy( 'noindex,nofollow' );
                $this->setArticleRelated( false );
 
@@ -2112,7 +2141,7 @@ class OutputPage {
                        if( $source ) {
                                $this->setPageTitle( wfMsg( 'viewsource' ) );
                                $this->setSubtitle(
-                                       wfMsg( 'viewsourcefor', $skin->linkKnown( $this->getTitle() ) )
+                                       wfMsg( 'viewsourcefor', $this->getSkin()->linkKnown( $this->getTitle() ) )
                                );
                        } else {
                                $this->setPageTitle( wfMsg( 'badaccess' ) );
@@ -2132,14 +2161,14 @@ class OutputPage {
                        $params = array(
                                'id'   => 'wpTextbox1',
                                'name' => 'wpTextbox1',
-                               'cols' => $wgUser->getOption( 'cols' ),
-                               'rows' => $wgUser->getOption( 'rows' ),
+                               'cols' => $this->getUser()->getOption( 'cols' ),
+                               'rows' => $this->getUser()->getOption( 'rows' ),
                                'readonly' => 'readonly'
                        );
                        $this->addHTML( Html::element( 'textarea', $params, $source ) );
 
                        // Show templates used by this article
-                       $skin = $wgUser->getSkin();
+                       $skin = $this->getSkin();
                        $article = new Article( $this->getTitle() );
                        $this->addHTML( "<div class='templatesUsed'>
 {$skin->formatTemplates( $article->getUsedTemplates() )}
@@ -2213,11 +2242,10 @@ class OutputPage {
         * @param $text String text of the link (input is not escaped)
         */
        public function addReturnTo( $title, $query = array(), $text = null ) {
-               global $wgUser;
                $this->addLink( array( 'rel' => 'next', 'href' => $title->getFullURL() ) );
                $link = wfMsgHtml(
                        'returnto',
-                       $wgUser->getSkin()->link( $title, $text, array(), $query )
+                       $this->getSkin()->link( $title, $text, array(), $query )
                );
                $this->addHTML( "<p id=\"mw-returnto\">{$link}</p>\n" );
        }
@@ -2265,7 +2293,7 @@ class OutputPage {
        public function headElement( Skin $sk, $includeStyle = true ) {
                global $wgOutputEncoding, $wgMimeType;
                global $wgUseTrackbacks, $wgHtml5;
-               global $wgUser, $wgRequest, $wgLang;
+               global $wgRequest, $wgLang;
 
                if ( $sk->commonPrintStylesheet() ) {
                        $this->addModuleStyles( 'mediawiki.legacy.wikiprintable' );
@@ -2310,7 +2338,7 @@ class OutputPage {
                if (
                        $this->getTitle()->getNamespace() != NS_SPECIAL &&
                        in_array( $action, array( 'view', 'purge' ) ) &&
-                       $wgUser->getOption( 'editondblclick' )
+                       $this->getUser()->getOption( 'editondblclick' )
                )
                {
                        $bodyAttrs['ondblclick'] = "document.location = '" . Xml::escapeJsString( $this->getTitle()->getEditURL() ) . "'";
@@ -2339,7 +2367,7 @@ class OutputPage {
         * Add the default ResourceLoader modules to this object
         */
        private function addDefaultModules() {
-               global $wgUser, $wgIncludeLegacyJavaScript,
+               global $wgIncludeLegacyJavaScript,
                        $wgUseAjax, $wgAjaxWatch, $wgEnableMWSuggest;
 
                // Add base resources
@@ -2354,16 +2382,16 @@ class OutputPage {
 
                        wfRunHooks( 'AjaxAddScript', array( &$this ) );
 
-                       if( $wgAjaxWatch && $wgUser->isLoggedIn() ) {
+                       if( $wgAjaxWatch && $this->getUser()->isLoggedIn() ) {
                                $this->addModules( 'mediawiki.action.watch.ajax' );
                        }
 
-                       if ( $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) {
+                       if ( $wgEnableMWSuggest && !$this->getUser()->getOption( 'disablesuggest', false ) ) {
                                $this->addModules( 'mediawiki.legacy.mwsuggest' );
                        }
                }
 
-               if( $wgUser->getBoolOption( 'editsectiononrightclick' ) ) {
+               if( $this->getUser()->getBoolOption( 'editsectiononrightclick' ) ) {
                        $this->addModules( 'mediawiki.action.view.rightClickEdit' );
                }
        }
@@ -2389,7 +2417,7 @@ class OutputPage {
         * @return string html <script> and <style> tags
         */
        protected function makeResourceLoaderLink( Skin $skin, $modules, $only, $useESI = false ) {
-               global $wgUser, $wgLang, $wgLoadScript, $wgResourceLoaderUseESI,
+               global $wgLang, $wgLoadScript, $wgResourceLoaderUseESI,
                        $wgResourceLoaderInlinePrivateModules, $wgRequest;
                // Lazy-load ResourceLoader
                // TODO: Should this be a static function of ResourceLoader instead?
@@ -2454,8 +2482,8 @@ class OutputPage {
                foreach ( $groups as $group => $modules ) {
                        $query = $baseQuery;
                        // Special handling for user-specific groups
-                       if ( ( $group === 'user' || $group === 'private' ) && $wgUser->isLoggedIn() ) {
-                               $query['user'] = $wgUser->getName();
+                       if ( ( $group === 'user' || $group === 'private' ) && $this->getUser()->isLoggedIn() ) {
+                               $query['user'] = $this->getUser()->getName();
                        }
                        
                        // Create a fake request based on the one we are about to make so modules return
@@ -2541,7 +2569,7 @@ class OutputPage {
         * @return String: HTML fragment
         */
        function getHeadScripts( Skin $sk ) {
-               global $wgUser, $wgRequest, $wgUseSiteJs, $wgAllowUserJs;
+               global $wgRequest, $wgUseSiteJs, $wgAllowUserJs;
 
                // Startup - this will immediately load jquery and mediawiki modules
                $scripts = $this->makeResourceLoaderLink( $sk, 'startup', ResourceLoaderModule::TYPE_SCRIPTS, true );
@@ -2571,13 +2599,13 @@ class OutputPage {
                // Add site JS if enabled
                if ( $wgUseSiteJs ) {
                        $scripts .= $this->makeResourceLoaderLink( $sk, 'site', ResourceLoaderModule::TYPE_SCRIPTS );
-                       if( $wgUser->isLoggedIn() ){
+                       if( $this->getUser()->isLoggedIn() ){
                                $userScripts[] = 'user.groups';
                        }
                }
 
                // Add user JS if enabled
-               if ( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
+               if ( $wgAllowUserJs && $this->getUser()->isLoggedIn() ) {
                        $action = $wgRequest->getVal( 'action', 'view' );
                        if( $this->mTitle && $this->mTitle->isJsSubpage() && $sk->userCanPreview( $action ) ) {
                                # XXX: additional security check/prompt?
@@ -2602,7 +2630,7 @@ class OutputPage {
         * have to be purged on configuration changes.
         */
        protected function getJSVars() {
-               global $wgUser, $wgRequest, $wgUseAjax, $wgEnableMWSuggest, $wgContLang;
+               global $wgRequest, $wgUseAjax, $wgEnableMWSuggest, $wgContLang;
 
                $title = $this->getTitle();
                $ns = $title->getNamespace();
@@ -2624,8 +2652,8 @@ class OutputPage {
                        'wgArticleId' => $title->getArticleId(),
                        'wgIsArticle' => $this->isArticle(),
                        'wgAction' => $wgRequest->getText( 'action', 'view' ),
-                       'wgUserName' => $wgUser->isAnon() ? null : $wgUser->getName(),
-                       'wgUserGroups' => $wgUser->getEffectiveGroups(),
+                       'wgUserName' => $this->getUser()->isAnon() ? null : $this->getUser()->getName(),
+                       'wgUserGroups' => $this->getUser()->getEffectiveGroups(),
                        'wgCategories' => $this->getCategories(),
                        'wgBreakFrames' => $this->getFrameOptions() == 'DENY',
                );
@@ -2635,8 +2663,8 @@ class OutputPage {
                foreach ( $title->getRestrictionTypes() as $type ) {
                        $vars['wgRestriction' . ucfirst( $type )] = $title->getRestrictions( $type );
                }
-               if ( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) {
-                       $vars['wgSearchNamespaces'] = SearchEngine::userNamespaces( $wgUser );
+               if ( $wgUseAjax && $wgEnableMWSuggest && !$this->getUser()->getOption( 'disablesuggest', false ) ) {
+                       $vars['wgSearchNamespaces'] = SearchEngine::userNamespaces( $this->getUser() );
                }
                
                // Allow extensions to add their custom variables to the global JS variables
index 89a015b..bdccf2a 100644 (file)
@@ -619,12 +619,13 @@ class SpecialPage {
         * @return String: HTML fragment
         */
        static function capturePath( &$title ) {
-               global $wgOut, $wgTitle;
+               global $wgOut, $wgTitle, $wgUser;
 
                $oldTitle = $wgTitle;
                $oldOut = $wgOut;
                $wgOut = new OutputPage;
                $wgOut->setTitle( $title );
+               $wgOut->setUser( $wgUser ); # for now, there may be a better idea in the future
 
                $ret = SpecialPage::executePath( $title, true );
                if ( $ret === true ) {
index ad5567d..714a8eb 100644 (file)
@@ -252,6 +252,7 @@ class ApiParse extends ApiBase {
 
                if ( isset( $prop['headitems'] ) || isset( $prop['headhtml'] ) ) {
                        $out = new OutputPage;
+                       $out->setUser( $wgUser );
                        $out->addParserOutputNoText( $p_result );
                        $userSkin = $wgUser->getSkin();