From b23194ab0e67b8226aae72b91a7b53ea39f7ca8b Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Thu, 26 Apr 2012 09:37:27 +0200 Subject: [PATCH] Use WikiPage::newFromID() instead of Title::newFromID() in refreshLinks.php. Avoids having to load twice the same row from the database. Change-Id: I3099dbd290e44f21677990e69200694c70aac63b --- maintenance/refreshLinks.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/maintenance/refreshLinks.php b/maintenance/refreshLinks.php index a7c7ec4ab9..26d7e29f28 100644 --- a/maintenance/refreshLinks.php +++ b/maintenance/refreshLinks.php @@ -174,10 +174,10 @@ class RefreshLinks extends Maintenance { * @param $id int The page_id of the redirect */ private function fixRedirect( $id ) { - $title = Title::newFromID( $id ); + $page = WikiPage::newFromID( $id ); $dbw = wfGetDB( DB_MASTER ); - if ( is_null( $title ) ) { + if ( $page === null ) { // This page doesn't exist (any more) // Delete any redirect table entry for it $dbw->delete( 'redirect', array( 'rd_from' => $id ), @@ -185,11 +185,10 @@ class RefreshLinks extends Maintenance { return; } - $page = WikiPage::factory( $title ); $rt = $page->getRedirectTarget(); if ( $rt === null ) { - // $title is not a redirect + // The page is not a redirect // Delete any redirect table entry for it $dbw->delete( 'redirect', array( 'rd_from' => $id ), __METHOD__ ); @@ -203,26 +202,27 @@ class RefreshLinks extends Maintenance { public static function fixLinksFromArticle( $id ) { global $wgParser, $wgContLang; - $title = Title::newFromID( $id ); - $dbw = wfGetDB( DB_MASTER ); + $page = WikiPage::newFromID( $id ); LinkCache::singleton()->clear(); - if ( is_null( $title ) ) { + if ( $page === null ) { return; } - $revision = Revision::newFromTitle( $title ); - if ( !$revision ) { + $text = $page->getRawText(); + if ( $text === false ) { return; } + $dbw = wfGetDB( DB_MASTER ); $dbw->begin( __METHOD__ ); $options = ParserOptions::newFromUserAndLang( new User, $wgContLang ); - $parserOutput = $wgParser->parse( $revision->getText(), $title, $options, true, true, $revision->getId() ); - $update = new LinksUpdate( $title, $parserOutput, false ); + $parserOutput = $wgParser->parse( $text, $page->getTitle(), $options, true, true, $page->getLatest() ); + $update = new LinksUpdate( $page->getTitle(), $parserOutput, false ); $update->doUpdate(); + $dbw->commit( __METHOD__ ); } -- 2.20.1