summaryrefslogtreecommitdiff
path: root/maintenance/refreshLinks.php
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/refreshLinks.php')
-rw-r--r--maintenance/refreshLinks.php43
1 files changed, 25 insertions, 18 deletions
diff --git a/maintenance/refreshLinks.php b/maintenance/refreshLinks.php
index c16b6963..3d9270b8 100644
--- a/maintenance/refreshLinks.php
+++ b/maintenance/refreshLinks.php
@@ -17,11 +17,17 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
+ * @file
* @ingroup Maintenance
*/
-require_once( dirname( __FILE__ ) . '/Maintenance.php' );
+require_once( __DIR__ . '/Maintenance.php' );
+/**
+ * Maintenance script to refresh link tables.
+ *
+ * @ingroup Maintenance
+ */
class RefreshLinks extends Maintenance {
public function __construct() {
parent::__construct();
@@ -174,10 +180,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 +191,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__ );
@@ -201,37 +206,38 @@ class RefreshLinks extends Maintenance {
* @param $id int The page_id
*/
public static function fixLinksFromArticle( $id ) {
- global $wgParser;
+ 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->begin();
+ $dbw = wfGetDB( DB_MASTER );
+ $dbw->begin( __METHOD__ );
- $options = new ParserOptions;
- $parserOutput = $wgParser->parse( $revision->getText(), $title, $options, true, true, $revision->getId() );
- $update = new LinksUpdate( $title, $parserOutput, false );
+ $options = ParserOptions::newFromUserAndLang( new User, $wgContLang );
+ $parserOutput = $wgParser->parse( $text, $page->getTitle(), $options, true, true, $page->getLatest() );
+ $update = new LinksUpdate( $page->getTitle(), $parserOutput, false );
$update->doUpdate();
- $dbw->commit();
+
+ $dbw->commit( __METHOD__ );
}
/**
* Removes non-existing links from pages from pagelinks, imagelinks,
* categorylinks, templatelinks, externallinks, interwikilinks, langlinks and redirect tables.
*
- * @param $maxLag
- * @param $batchSize The size of deletion batches
+ * @param $maxLag int
+ * @param $batchSize int The size of deletion batches
*
* @author Merlijn van Deen <valhallasw@arctus.nl>
*/
@@ -287,6 +293,7 @@ class RefreshLinks extends Maintenance {
$dbw->delete( $table, array( $field => $list ), __METHOD__ );
}
$this->output( "\n" );
+ wfWaitForSlaves();
}
$lb->closeAll();
}