<?php
/**
- * quick hackjob to fix damages imports on wikisource
- * page records have page_latest wrong
+ * Corrects wrong values in the `page_latest` field in the database.
*
- * Copyright (C) 2005 Brion Vibber <brion@pobox.com>
+ * Copyright © 2005 Brion Vibber <brion@pobox.com>
* http://www.mediawiki.org/
*
* This program is free software; you can redistribute it and/or modify
* 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 correct wrong values in the `page_latest` field
+ * in the database.
+ *
+ * @ingroup Maintenance
+ */
class AttachLatest extends Maintenance {
-
+
public function __construct() {
parent::__construct();
$this->addOption( "fix", "Actually fix the entries, will dry run otherwise" );
$this->mDescription = "Fix page_latest entries in the page table";
}
-
+
public function execute() {
$this->output( "Looking for pages with page_latest set to 0...\n" );
$dbw = wfGetDB( DB_MASTER );
$this->output( wfWikiID() . " $pageId [[$name]] can't find latest rev time?!\n" );
continue;
}
-
+
$revision = Revision::loadFromTimestamp( $dbw, $title, $latestTime );
if ( is_null( $revision ) ) {
$this->output( wfWikiID() . " $pageId [[$name]] latest time $latestTime, can't find revision id\n" );
$id = $revision->getId();
$this->output( wfWikiID() . " $pageId [[$name]] latest time $latestTime, rev id $id\n" );
if ( $this->hasOption( 'fix' ) ) {
- $article = new Article( $title );
- $article->updateRevisionOn( $dbw, $revision );
+ $page = WikiPage::factory( $title );
+ $page->updateRevisionOn( $dbw, $revision );
}
$n++;
}
}
$maintClass = "AttachLatest";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );