*/
public function loadPageData( $data = 'fromdb' ) {
if ( $data === 'fromdb' ) {
- $dbr = wfGetDB( DB_MASTER );
- $data = $this->pageDataFromId( $dbr, $this->getId() );
+ $dbr = wfGetDB( DB_SLAVE );
+ $data = $this->pageDataFromTitle( $dbr, $this->mTitle );
}
$lc = LinkCache::singleton();
return $this->mContent;
}
- $dbr = wfGetDB( DB_MASTER );
-
# Pre-fill content with error message so that if something
# fails we'll have something telling us what we intended.
$t = $this->mTitle->getPrefixedText();
return false;
}
- $data = $this->pageDataFromId( $dbr, $revision->getPage() );
-
- if ( !$data ) {
- wfDebug( __METHOD__ . " failed to get page data linked to revision id $oldid\n" );
- return false;
- }
-
- $this->mTitle = Title::makeTitle( $data->page_namespace, $data->page_title );
- $this->loadPageData( $data );
- } else {
- if ( !$this->mDataLoaded ) {
- $data = $this->pageDataFromTitle( $dbr, $this->mTitle );
+ if ( !$this->mDataLoaded || $this->getID() != $revision->getPage() ) {
+ $data = $this->pageDataFromId( wfGetDB( DB_SLAVE ), $revision->getPage() );
if ( !$data ) {
- wfDebug( __METHOD__ . " failed to find page data for title " . $this->mTitle->getPrefixedText() . "\n" );
+ wfDebug( __METHOD__ . " failed to get page data linked to revision id $oldid\n" );
return false;
}
+ $this->mTitle = Title::makeTitle( $data->page_namespace, $data->page_title );
$this->loadPageData( $data );
}
+ } else {
+ if ( !$this->mDataLoaded ) {
+ $this->loadPageData();
+ }
+
+ if ( $this->mLatest === false ) {
+ wfDebug( __METHOD__ . " failed to find page data for title " . $this->mTitle->getPrefixedText() . "\n" );
+ return false;
+ }
+
$revision = Revision::newFromId( $this->mLatest );
- if ( $revision === null ) {
+ if ( $revision === null ) {
wfDebug( __METHOD__ . " failed to retrieve current page, rev_id {$this->mLatest}\n" );
return false;
}
// Give extensions a change to ignore/handle redirects as needed
$ignoreRedirect = $target = false;
- $dbr = wfGetDB( DB_SLAVE );
- $article->loadPageData( $article->pageDataFromTitle( $dbr, $title ) );
-
wfRunHooks( 'InitializeArticleMaybeRedirect',
array(&$title,&$request,&$ignoreRedirect,&$target,&$article) );
if( is_object($target) ) {
// Rewrite environment to redirected article
$rarticle = self::articleFromTitle( $target );
- $rarticle->loadPageData( $rarticle->pageDataFromTitle( $dbr, $target ) );
+ $rarticle->loadPageData();
if( $rarticle->exists() || ( is_object( $file ) && !$file->isLocal() ) ) {
$rarticle->setRedirectedFrom( $title );
$article = $rarticle;