Index: trunk/phase3/includes/Article.php |
— | — | @@ -468,8 +468,8 @@ |
469 | 469 | */ |
470 | 470 | public function loadPageData( $data = 'fromdb' ) { |
471 | 471 | if ( $data === 'fromdb' ) { |
472 | | - $dbr = wfGetDB( DB_MASTER ); |
473 | | - $data = $this->pageDataFromId( $dbr, $this->getId() ); |
| 472 | + $dbr = wfGetDB( DB_SLAVE ); |
| 473 | + $data = $this->pageDataFromTitle( $dbr, $this->mTitle ); |
474 | 474 | } |
475 | 475 | |
476 | 476 | $lc = LinkCache::singleton(); |
— | — | @@ -506,8 +506,6 @@ |
507 | 507 | return $this->mContent; |
508 | 508 | } |
509 | 509 | |
510 | | - $dbr = wfGetDB( DB_MASTER ); |
511 | | - |
512 | 510 | # Pre-fill content with error message so that if something |
513 | 511 | # fails we'll have something telling us what we intended. |
514 | 512 | $t = $this->mTitle->getPrefixedText(); |
— | — | @@ -521,28 +519,29 @@ |
522 | 520 | return false; |
523 | 521 | } |
524 | 522 | |
525 | | - $data = $this->pageDataFromId( $dbr, $revision->getPage() ); |
| 523 | + if ( !$this->mDataLoaded || $this->getID() != $revision->getPage() ) { |
| 524 | + $data = $this->pageDataFromId( wfGetDB( DB_SLAVE ), $revision->getPage() ); |
526 | 525 | |
527 | | - if ( !$data ) { |
528 | | - wfDebug( __METHOD__ . " failed to get page data linked to revision id $oldid\n" ); |
529 | | - return false; |
530 | | - } |
531 | | - |
532 | | - $this->mTitle = Title::makeTitle( $data->page_namespace, $data->page_title ); |
533 | | - $this->loadPageData( $data ); |
534 | | - } else { |
535 | | - if ( !$this->mDataLoaded ) { |
536 | | - $data = $this->pageDataFromTitle( $dbr, $this->mTitle ); |
537 | | - |
538 | 526 | if ( !$data ) { |
539 | | - wfDebug( __METHOD__ . " failed to find page data for title " . $this->mTitle->getPrefixedText() . "\n" ); |
| 527 | + wfDebug( __METHOD__ . " failed to get page data linked to revision id $oldid\n" ); |
540 | 528 | return false; |
541 | 529 | } |
542 | 530 | |
| 531 | + $this->mTitle = Title::makeTitle( $data->page_namespace, $data->page_title ); |
543 | 532 | $this->loadPageData( $data ); |
544 | 533 | } |
| 534 | + } else { |
| 535 | + if ( !$this->mDataLoaded ) { |
| 536 | + $this->loadPageData(); |
| 537 | + } |
| 538 | + |
| 539 | + if ( $this->mLatest === false ) { |
| 540 | + wfDebug( __METHOD__ . " failed to find page data for title " . $this->mTitle->getPrefixedText() . "\n" ); |
| 541 | + return false; |
| 542 | + } |
| 543 | + |
545 | 544 | $revision = Revision::newFromId( $this->mLatest ); |
546 | | - if ( $revision === null ) { |
| 545 | + if ( $revision === null ) { |
547 | 546 | wfDebug( __METHOD__ . " failed to retrieve current page, rev_id {$this->mLatest}\n" ); |
548 | 547 | return false; |
549 | 548 | } |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -349,9 +349,6 @@ |
350 | 350 | // Give extensions a change to ignore/handle redirects as needed |
351 | 351 | $ignoreRedirect = $target = false; |
352 | 352 | |
353 | | - $dbr = wfGetDB( DB_SLAVE ); |
354 | | - $article->loadPageData( $article->pageDataFromTitle( $dbr, $title ) ); |
355 | | - |
356 | 353 | wfRunHooks( 'InitializeArticleMaybeRedirect', |
357 | 354 | array(&$title,&$request,&$ignoreRedirect,&$target,&$article) ); |
358 | 355 | |
— | — | @@ -370,7 +367,7 @@ |
371 | 368 | if( is_object($target) ) { |
372 | 369 | // Rewrite environment to redirected article |
373 | 370 | $rarticle = self::articleFromTitle( $target ); |
374 | | - $rarticle->loadPageData( $rarticle->pageDataFromTitle( $dbr, $target ) ); |
| 371 | + $rarticle->loadPageData(); |
375 | 372 | if( $rarticle->exists() || ( is_object( $file ) && !$file->isLocal() ) ) { |
376 | 373 | $rarticle->setRedirectedFrom( $title ); |
377 | 374 | $article = $rarticle; |