https://www.mediawiki.org/wiki/Special:Code/MediaWiki/108274
Revision: 108274
Author: ialex
Date: 2012-01-06 20:00:04 +0000 (Fri, 06 Jan 2012)
Log Message:
-----------
* Added WikiPage to RequestContext and related so that it can be shared to
avoid creating a new object each time and thus avoiding database queries to
load the state of the object
* Added Article::getPage() as accessor to the WikiPage object so that it can be
set in the context from MediaWiki::initializeArticle()
* Use it WikiPage::main() to call doViewUpdates()
I'm doing to this now so that I can revert r105790 and use the WikiPage object
before the 1.19 release
Modified Paths:
--------------
trunk/phase3/includes/Article.php
trunk/phase3/includes/Wiki.php
trunk/phase3/includes/context/ContextSource.php
trunk/phase3/includes/context/DerivativeContext.php
trunk/phase3/includes/context/IContextSource.php
trunk/phase3/includes/context/RequestContext.php
Modified: trunk/phase3/includes/Article.php
===================================================================
--- trunk/phase3/includes/Article.php 2012-01-06 19:49:30 UTC (rev 108273)
+++ trunk/phase3/includes/Article.php 2012-01-06 20:00:04 UTC (rev 108274)
@@ -150,6 +150,7 @@
/**
* Get the title object of the article
+ *
* @return Title object of this page
*/
public function getTitle() {
@@ -157,6 +158,16 @@
}
/**
+ * Get the WikiPage object of this instance
+ *
+ * @since 1.19
+ * @return WikiPage
+ */
+ public function getPage() {
+ return $this->mPage;
+ }
+
+ /**
* Clear the object
*/
public function clear() {
Modified: trunk/phase3/includes/Wiki.php
===================================================================
--- trunk/phase3/includes/Wiki.php 2012-01-06 19:49:30 UTC (rev 108273)
+++ trunk/phase3/includes/Wiki.php 2012-01-06 20:00:04 UTC (rev 108274)
@@ -337,19 +337,21 @@
wfProfileIn( __METHOD__ );
- $request = $this->context->getRequest();
$title = $this->context->getTitle();
-
- $action = $request->getVal( 'action', 'view' );
$article = Article::newFromTitle( $title, $this->context );
+ $this->context->setWikiPage( $article->getPage() );
// NS_MEDIAWIKI has no redirects.
// It is also used for CSS/JS, so performance matters here...
if ( $title->getNamespace() == NS_MEDIAWIKI ) {
wfProfileOut( __METHOD__ );
return $article;
}
+
+ $request = $this->context->getRequest();
+
// Namespace might change when using redirects
// Check for redirects ...
+ $action = $request->getVal( 'action', 'view' );
$file = ( $title->getNamespace() == NS_FILE ) ?
$article->getFile() : null;
if ( ( $action == 'view' || $action == 'render' ) // ...
for actions that show content
&& !$request->getVal( 'oldid' ) && // ... and are
not old revisions
@@ -384,10 +386,12 @@
$rarticle->setRedirectedFrom(
$title );
$article = $rarticle;
$this->context->setTitle(
$target );
+ $this->context->setWikiPage(
$article->getPage() );
}
}
} else {
$this->context->setTitle( $article->getTitle()
);
+ $this->context->setWikiPage(
$article->getPage() );
}
}
@@ -604,8 +608,7 @@
$cache->loadFromFileCache(
$this->context );
}
# Do any stats increment/watchlist stuff
- $page = WikiPage::factory(
$this->getTitle() );
- $page->doViewUpdates(
$this->context->getUser() );
+
$this->context->getWikiPage()->doViewUpdates( $this->context->getUser() );
# Tell OutputPage that output is taken
care of
$this->context->getOutput()->disable();
wfProfileOut( 'main-try-filecache' );
Modified: trunk/phase3/includes/context/ContextSource.php
===================================================================
--- trunk/phase3/includes/context/ContextSource.php 2012-01-06 19:49:30 UTC
(rev 108273)
+++ trunk/phase3/includes/context/ContextSource.php 2012-01-06 20:00:04 UTC
(rev 108274)
@@ -79,6 +79,16 @@
}
/**
+ * Get the WikiPage object
+ *
+ * @since 1.19
+ * @return WikiPage
+ */
+ public function getWikiPage() {
+ return $this->getContext()->getWikiPage();
+ }
+
+ /**
* Get the OutputPage object
*
* @since 1.18
Modified: trunk/phase3/includes/context/DerivativeContext.php
===================================================================
--- trunk/phase3/includes/context/DerivativeContext.php 2012-01-06 19:49:30 UTC
(rev 108273)
+++ trunk/phase3/includes/context/DerivativeContext.php 2012-01-06 20:00:04 UTC
(rev 108274)
@@ -42,6 +42,11 @@
private $title;
/**
+ * @var WikiPage
+ */
+ private $wikipage;
+
+ /**
* @var OutputPage
*/
private $output;
@@ -114,6 +119,32 @@
}
/**
+ * Set the WikiPage object
+ *
+ * @since 1.19
+ * @param $p WikiPage object
+ */
+ public function setWikiPage( WikiPage $p ) {
+ $this->wikipage = $p;
+ }
+
+ /**
+ * Get the WikiPage object
+ *
+ * @since 1.19
+ * @return WikiPage
+ */
+ public function getWikiPage() {
+ if ( !is_null( $this->wikipage ) ) {
+ return $this->wikipage;
+ } else {
+ return $this->getContext()->getWikiPage();
+ }
+ }
+
+ /**
+ * Set the OutputPage object
+ *
* @param $o OutputPage
*/
public function setOutput( OutputPage $o ) {
Modified: trunk/phase3/includes/context/IContextSource.php
===================================================================
--- trunk/phase3/includes/context/IContextSource.php 2012-01-06 19:49:30 UTC
(rev 108273)
+++ trunk/phase3/includes/context/IContextSource.php 2012-01-06 20:00:04 UTC
(rev 108274)
@@ -43,6 +43,14 @@
public function getTitle();
/**
+ * Get the WikiPage object
+ *
+ * @since 1.19
+ * @return WikiPage
+ */
+ public function getWikiPage();
+
+ /**
* Get the OutputPage object
*
* @return OutputPage object
Modified: trunk/phase3/includes/context/RequestContext.php
===================================================================
--- trunk/phase3/includes/context/RequestContext.php 2012-01-06 19:49:30 UTC
(rev 108273)
+++ trunk/phase3/includes/context/RequestContext.php 2012-01-06 20:00:04 UTC
(rev 108274)
@@ -40,6 +40,11 @@
private $title;
/**
+ * @var WikiPage
+ */
+ private $wikipage;
+
+ /**
* @var OutputPage
*/
private $output;
@@ -104,6 +109,33 @@
}
/**
+ * Set the WikiPage object
+ *
+ * @since 1.19
+ * @param $p WikiPage object
+ */
+ public function setWikiPage( WikiPage $p ) {
+ $this->wikipage = $p;
+ }
+
+ /**
+ * Get the WikiPage object
+ *
+ * @since 1.19
+ * @return WikiPage
+ */
+ public function getWikiPage() {
+ if ( $this->wikipage === null ) {
+ $title = $this->getTitle();
+ if ( $title === null ) {
+ throw new MWException( __METHOD__ . ' called
without Title object set' );
+ }
+ $this->wikipage = WikiPage::factory( $title );
+ }
+ return $this->wikipage;
+ }
+
+ /**
* @param $o OutputPage
*/
public function setOutput( OutputPage $o ) {
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs