Fix mctest to work with new WMF memcached setup
[lhc/web/wiklou.git] / maintenance / attachLatest.php
index 6db5d6d..475cafc 100644 (file)
@@ -1,9 +1,8 @@
 <?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 );
@@ -55,7 +61,7 @@ class AttachLatest extends Maintenance {
                                $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" );
@@ -64,8 +70,8 @@ class AttachLatest extends Maintenance {
                        $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++;
                }
@@ -77,4 +83,4 @@ class AttachLatest extends Maintenance {
 }
 
 $maintClass = "AttachLatest";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );