From: Daniel Friesen Date: Mon, 4 Apr 2011 00:18:33 +0000 (+0000) Subject: Update index.php and Wiki.php to make better use of the context. X-Git-Tag: 1.31.0-rc.0~31039 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=ff33175e96697dce4ac215993f4e6ef9c26a0525;p=lhc%2Fweb%2Fwiklou.git Update index.php and Wiki.php to make better use of the context. --- diff --git a/includes/RequestContext.php b/includes/RequestContext.php index b0c4ecdf3c..4fd7222467 100644 --- a/includes/RequestContext.php +++ b/includes/RequestContext.php @@ -59,15 +59,6 @@ class RequestContext { return $this->mTitle; } - /** - * Set the OutputPage object - * - * @param $u OutputPage - */ - public function setOutput( OutputPage $o ) { - $this->mOutput = $o; - } - /** * Get the OutputPage object * diff --git a/includes/Setup.php b/includes/Setup.php index 37d9a4732e..9bfe418078 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -365,7 +365,7 @@ $wgContLang = new StubContLang; // Now that variant lists may be available... $wgRequest->interpolateTitle(); -$wgUser = $wgCommandLineMode ? new User : User::newFromSession(); +$wgUser = RequestContext::getMain()->user; # BackCompat /** * @var Language @@ -375,7 +375,7 @@ $wgLang = new StubUserLang; /** * @var OutputPage */ -$wgOut = new OutputPage; +$wgOut = RequestContext::getMain()->output; # BackCompat /** * @var Parser diff --git a/includes/Wiki.php b/includes/Wiki.php index 6ef86f1a1a..b8c966b9fc 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -56,10 +56,8 @@ class MediaWiki { return wfSetVar( $this->context->output, $x ); } - public function __construct( WebRequest &$request, /*OutputPage*/ &$output ){ - $this->context = new RequestContext(); - $this->context->setRequest( $request ); - $this->context->setOutput( $output ); + public function __construct( RequestContext $context ){ + $this->context = $context; $this->context->setTitle( $this->parseTitle() ); } @@ -68,9 +66,8 @@ class MediaWiki { * Performs the request too * * @param $article Article - * @param $user User */ - public function performRequestForTitle( &$article, &$user ) { + public function performRequestForTitle( &$article ) { wfProfileIn( __METHOD__ ); if ( $this->context->request->getVal( 'printable' ) === 'yes' ) { @@ -81,7 +78,7 @@ class MediaWiki { &$this->context->title, &$article, &$this->context->output, - &$user, + &$this->context->user, $this->context->request, $this ) ); @@ -104,7 +101,7 @@ class MediaWiki { $new_article = $this->initializeArticle(); if ( is_object( $new_article ) ) { $article = $new_article; - $this->performAction( $article, $user ); + $this->performAction( $article ); } elseif ( is_string( $new_article ) ) { $this->context->output->redirect( $new_article ); } else { @@ -454,14 +451,13 @@ class MediaWiki { * Perform one of the "standard" actions * * @param $article Article - * @param $user User */ - private function performAction( &$article, &$user ) { + private function performAction( &$article ) { wfProfileIn( __METHOD__ ); if ( !wfRunHooks( 'MediaWikiPerformAction', array( $this->context->output, $article, $this->context->title, - $user, $this->context->request, $this ) ) ) + $this->context->user, $this->context->request, $this ) ) ) { wfProfileOut( __METHOD__ ); return; @@ -523,16 +519,16 @@ class MediaWiki { } /* Continue... */ case 'edit': - if ( wfRunHooks( 'CustomEditor', array( $article, $user ) ) ) { + if ( wfRunHooks( 'CustomEditor', array( $article, $this->context->user ) ) ) { $internal = $this->context->request->getVal( 'internaledit' ); $external = $this->context->request->getVal( 'externaledit' ); $section = $this->context->request->getVal( 'section' ); $oldid = $this->context->request->getVal( 'oldid' ); if ( !$this->getVal( 'UseExternalEditor' ) || $action == 'submit' || $internal || - $section || $oldid || ( !$user->getOption( 'externaleditor' ) && !$external ) ) { + $section || $oldid || ( !$this->context->user->getOption( 'externaleditor' ) && !$external ) ) { $editor = new EditPage( $article ); $editor->submit(); - } elseif ( $this->getVal( 'UseExternalEditor' ) && ( $external || $user->getOption( 'externaleditor' ) ) ) { + } elseif ( $this->getVal( 'UseExternalEditor' ) && ( $external || $this->context->user->getOption( 'externaleditor' ) ) ) { $mode = $this->context->request->getVal( 'mode' ); $extedit = new ExternalEdit( $article, $mode ); $extedit->edit(); diff --git a/index.php b/index.php index 560ee92535..8faead547c 100644 --- a/index.php +++ b/index.php @@ -63,7 +63,8 @@ if ( !is_null( $maxLag ) ) { } # Initialize MediaWiki base class -$mediaWiki = new MediaWiki( $wgRequest, $wgOut ); +$context = RequestContext::getMain(); +$mediaWiki = new MediaWiki( $context ); # Set title from request parameters $wgTitle = $mediaWiki->getTitle(); @@ -89,14 +90,14 @@ if ( $wgUseFileCache && $wgTitle !== null ) { $cache = new HTMLFileCache( $wgTitle, $action ); if ( $cache->isFileCacheGood( /* Assume up to date */ ) ) { /* Check incoming headers to see if client has this cached */ - if ( !$wgOut->checkLastModified( $cache->fileCacheTime() ) ) { + if ( !$context->output->checkLastModified( $cache->fileCacheTime() ) ) { $cache->loadFromFileCache(); } # Do any stats increment/watchlist stuff $wgArticle = MediaWiki::articleFromTitle( $wgTitle ); $wgArticle->viewUpdates(); - # Tell $wgOut that output is taken care of - $wgOut->disable(); + # Tell OutputPage that output is taken care of + $context->output->disable(); wfProfileOut( 'index.php-filecache' ); $mediaWiki->finalCleanup(); wfProfileOut( 'index.php' ); @@ -116,7 +117,7 @@ $mediaWiki->setVal( 'SquidMaxage', $wgSquidMaxage ); $mediaWiki->setVal( 'UseExternalEditor', $wgUseExternalEditor ); $mediaWiki->setVal( 'UsePathInfo', $wgUsePathInfo ); -$mediaWiki->performRequestForTitle( $wgArticle, $wgUser ); +$mediaWiki->performRequestForTitle( $wgArticle ); $mediaWiki->finalCleanup(); wfProfileOut( 'index.php' );