mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 09:49:31 +02:00
Fix maintenance script.
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2012-2014 Daniel Kraus <krada@gmx.net> ('bovender')
|
||||
* Copyright 2012-2016 Daniel Kraus <bovender@bovender.de> ('bovender')
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -17,20 +17,21 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301, USA.
|
||||
*/
|
||||
namespace LinkTitles;
|
||||
|
||||
// Attempt to include the maintenance base class from:
|
||||
// $wgScriptPath/maintenance/Maintenance.php
|
||||
// Our script is normally located at:
|
||||
// $wgScriptPath/extensions/LinkTitles/LinkTitles.cli.php
|
||||
$maintenanceScript = dirname( __FILE__ ) . "/../../maintenance/Maintenance.php";
|
||||
// $wgScriptPath/extensions/LinkTitles/LinkTitles_Maintenance.php
|
||||
$maintenanceScript = __DIR__ . "/../../maintenance/Maintenance.php";
|
||||
if ( file_exists( $maintenanceScript ) ) {
|
||||
require_once $maintenanceScript;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Did not find the script where we expected it (maybe because we are a
|
||||
// symlinked file -- __FILE__ resolves symbolic links).
|
||||
$maintenanceScript = dirname( __FILE__ ) . "/Maintenance.php";
|
||||
// symlinked file -- __DIR resolves symbolic links).
|
||||
$maintenanceScript = __DIR__ . "/Maintenance.php";
|
||||
if ( file_exists( $maintenanceScript ) ) {
|
||||
require_once $maintenanceScript;
|
||||
}
|
||||
@ -39,11 +40,11 @@ else
|
||||
die("FATAL: Could not locate Maintenance.php.\n" .
|
||||
"You may want to create a symbolic link named Maintenance.php in this directory\n" .
|
||||
"which points to <YOUR_MEDIAWIKI_ROOT_IN_FILESYSTEM>/extensions/Maintenance.php\n" .
|
||||
"Ex.: ln -s /var/www/wiki/extensions/Maintenance.php\n\n");
|
||||
"Ex.: ln -s /var/www/wiki/maintenance/Maintenance.php\n\n");
|
||||
}
|
||||
};
|
||||
|
||||
require_once( dirname( __FILE__ ) . "/LinkTitles.body.php" );
|
||||
require_once( __DIR__ . "/includes/LinkTitles_Extension.php" );
|
||||
|
||||
/// Core class of the maintanance script.
|
||||
/// @note Note that the execution of maintenance scripts is prohibited for
|
||||
@ -52,7 +53,7 @@ require_once( dirname( __FILE__ ) . "/LinkTitles.body.php" );
|
||||
/// anybody who is able to execute this script may place a high load on the
|
||||
/// server.
|
||||
/// @ingroup batch
|
||||
class LinkTitlesCli extends Maintenance {
|
||||
class Cli extends \Maintenance {
|
||||
/// The constructor adds a description and one option.
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
@ -93,7 +94,7 @@ class LinkTitlesCli extends Maintenance {
|
||||
)
|
||||
);
|
||||
$numPages = $res->numRows();
|
||||
$context = RequestContext::getMain();
|
||||
$context = \RequestContext::getMain();
|
||||
$this->output("Processing ${numPages} pages, starting at index ${index}...\n");
|
||||
|
||||
// Iterate through the pages; break if a time limit is exceeded.
|
||||
@ -103,18 +104,18 @@ class LinkTitlesCli extends Maintenance {
|
||||
$this->output(
|
||||
sprintf("\rPage #%d (%02.0f%%)", $index, $index / $numPages * 100)
|
||||
);
|
||||
LinkTitles::processPage($curTitle, $context);
|
||||
Extension::processPage($curTitle, $context);
|
||||
}
|
||||
|
||||
$this->output("\nFinished parsing.\n");
|
||||
}
|
||||
}
|
||||
|
||||
$maintClass = 'LinkTitlesCli';
|
||||
$maintClass = 'LinkTitles\Cli';
|
||||
if( defined('RUN_MAINTENANCE_IF_MAIN') ) {
|
||||
require_once( RUN_MAINTENANCE_IF_MAIN );
|
||||
} else {
|
||||
require_once( DO_MAINTENANCE ); # Make this work on versions before 1.17
|
||||
require_once( DO_MAINTENANCE );
|
||||
}
|
||||
|
||||
// vim: ts=2:sw=2:noet:comments^=\:///
|
Reference in New Issue
Block a user