Revise Special class.

- Change: The $wgLinkTitlesBatchTimeLimit configuration variable was renamed to $wgLinkTitlesSpecialPageReloadAfter.
This commit is contained in:
Daniel Kraus
2017-08-27 23:06:43 +02:00
parent f1eae017b9
commit 2c0eb6839b
4 changed files with 35 additions and 29 deletions

View File

@ -27,7 +27,7 @@
"LinkTitlesSmartMode": true,
"LinkTitlesWordStartOnly": true,
"LinkTitlesWordEndOnly": true,
"LinkTitlesBatchTimeLimit": 1,
"LinkTitlesSpecialPageReloadAfter": 1,
"LinkTitlesNamespaces": [
0
]

View File

@ -149,6 +149,12 @@ class Config {
*/
public $enableNoTargetMagicWord;
/**
* Time (in seconds) after which to reload the special page.
* @var integer reload interval (in seconds)
*/
public $specialPageReloadAfter;
public $enableConsoleOutput;
public $enableDebugConsoleOutput;
@ -174,6 +180,7 @@ class Config {
global $wgLinkTitlesParseHeadings;
global $wgLinkTitlesEnableNoTargetMagicWord;
global $wgLinkTitlesCheckRedirect;
global $wgLinkTitlesSpecialPageReloadAfter;
$this->parseOnEdit = $wgLinkTitlesParseOnEdit;
$this->parseOnRender = $wgLinkTitlesParseOnRender;
$this->preferShortTitles = $wgLinkTitlesPreferShortTitles;
@ -189,6 +196,7 @@ class Config {
$this->parseHeadings = $wgLinkTitlesParseHeadings;
$this->enableNoTargetMagicWord = $wgLinkTitlesEnableNoTargetMagicWord;;
$this->checkRedirect = $wgLinkTitlesCheckRedirect;;
$this->specialPageReloadAfter = $wgLinkTitlesSpecialPageReloadAfter;
$this->enableConsoleOutput = false;
$this->enableDebugConsoleOutput = false;
}

View File

@ -37,6 +37,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
*
*/
class Special extends \SpecialPage {
private $config;
/**
* Constructor. Announces the special page title and required user right to the parent constructor.
@ -46,6 +47,7 @@ class Special extends \SpecialPage {
// users who have the 'linktitles-batch' right get to see this page (by
// default, this are all sysop users).
parent::__construct( 'LinkTitles', 'linktitles-batch' );
$this->config = new Config();
}
function getGroupName() {
@ -94,11 +96,8 @@ class Special extends \SpecialPage {
* @param OutputPage $output Output page for the special page.
*/
private function process( \WebRequest &$request, \OutputPage &$output) {
global $wgLinkTitlesTimeLimit;
global $wgLinkTitlesNamespaces;
// get our Namespaces
$namespacesClause = str_replace( '_', ' ','(' . implode( ', ',$wgLinkTitlesNamespaces ) . ')' );
$namespacesClause = str_replace( '_', ' ','(' . implode( ', ',$this->config->nameSpaces ) . ')' );
// Start the stopwatch
$startTime = microtime( true );
@ -147,7 +146,7 @@ class Special extends \SpecialPage {
$start += 1;
// Check if the time limit is exceeded
if ( microtime(true)-$startTime > $wgLinkTitlesTimeLimit )
if ( microtime( true ) - $startTime > $config->specialPageReloadAfter )
{
break;
}
@ -244,14 +243,14 @@ EOF
);
}
/*
/**
* Generates an HTML form and JavaScript to automatically submit the
* form.
* @param $url URL to reload with a POST request.
* @param $start Index of the next page that shall be processed.
* @param $end Index of the last page to be processed.
* @param $reloads Counter that holds the number of reloads so far.
* @returns String that holds the HTML for a form and a JavaScript command.
* @return String that holds the HTML for a form and a JavaScript command.
*/
private function getReloaderForm( $url, $start, $end, $reloads ) {
return
@ -268,16 +267,15 @@ EOF
;
}
/*
/**
* Adds statistics to the page when all processing is done.
* @param $output Output object
* @param $start Index of the first page that was processed.
* @param $end Index of the last processed page.
* @param $reloads Number of reloads of the page.
* @returns undefined
* @return undefined
*/
private function addCompletedInfo( &$output, $start, $end, $reloads ) {
global $wgLinkTitlesTimeLimit;
$pagesPerReload = sprintf('%0.1f', $end / $reloads);
$output->addWikiText(
<<<EOF
@ -286,7 +284,7 @@ EOF
|-
| total number of pages: || ${end}
|-
| timeout setting [s]: || ${wgLinkTitlesTimeLimit}
| timeout setting [s]: || {$config->specialPageReloadAfter}
|-
| webpage reloads: || ${reloads}
|-
@ -296,10 +294,10 @@ EOF
);
}
/*
/**
* Counts the number of pages in a read-access wiki database ($dbr).
* @param $dbr Read-only `Database` object.
* @returns Number of pages in the default namespace (0) of the wiki.
* @return Number of pages in the default namespace (0) of the wiki.
*/
private function countPages( &$dbr, $namespacesClause ) {
$res = $dbr->select(