mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 09:49:31 +02:00
Revise Special class.
- Change: The $wgLinkTitlesBatchTimeLimit configuration variable was renamed to $wgLinkTitlesSpecialPageReloadAfter.
This commit is contained in:
@ -27,7 +27,7 @@
|
|||||||
"LinkTitlesSmartMode": true,
|
"LinkTitlesSmartMode": true,
|
||||||
"LinkTitlesWordStartOnly": true,
|
"LinkTitlesWordStartOnly": true,
|
||||||
"LinkTitlesWordEndOnly": true,
|
"LinkTitlesWordEndOnly": true,
|
||||||
"LinkTitlesBatchTimeLimit": 1,
|
"LinkTitlesSpecialPageReloadAfter": 1,
|
||||||
"LinkTitlesNamespaces": [
|
"LinkTitlesNamespaces": [
|
||||||
0
|
0
|
||||||
]
|
]
|
||||||
|
@ -149,6 +149,12 @@ class Config {
|
|||||||
*/
|
*/
|
||||||
public $enableNoTargetMagicWord;
|
public $enableNoTargetMagicWord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time (in seconds) after which to reload the special page.
|
||||||
|
* @var integer reload interval (in seconds)
|
||||||
|
*/
|
||||||
|
public $specialPageReloadAfter;
|
||||||
|
|
||||||
public $enableConsoleOutput;
|
public $enableConsoleOutput;
|
||||||
public $enableDebugConsoleOutput;
|
public $enableDebugConsoleOutput;
|
||||||
|
|
||||||
@ -174,6 +180,7 @@ class Config {
|
|||||||
global $wgLinkTitlesParseHeadings;
|
global $wgLinkTitlesParseHeadings;
|
||||||
global $wgLinkTitlesEnableNoTargetMagicWord;
|
global $wgLinkTitlesEnableNoTargetMagicWord;
|
||||||
global $wgLinkTitlesCheckRedirect;
|
global $wgLinkTitlesCheckRedirect;
|
||||||
|
global $wgLinkTitlesSpecialPageReloadAfter;
|
||||||
$this->parseOnEdit = $wgLinkTitlesParseOnEdit;
|
$this->parseOnEdit = $wgLinkTitlesParseOnEdit;
|
||||||
$this->parseOnRender = $wgLinkTitlesParseOnRender;
|
$this->parseOnRender = $wgLinkTitlesParseOnRender;
|
||||||
$this->preferShortTitles = $wgLinkTitlesPreferShortTitles;
|
$this->preferShortTitles = $wgLinkTitlesPreferShortTitles;
|
||||||
@ -189,6 +196,7 @@ class Config {
|
|||||||
$this->parseHeadings = $wgLinkTitlesParseHeadings;
|
$this->parseHeadings = $wgLinkTitlesParseHeadings;
|
||||||
$this->enableNoTargetMagicWord = $wgLinkTitlesEnableNoTargetMagicWord;;
|
$this->enableNoTargetMagicWord = $wgLinkTitlesEnableNoTargetMagicWord;;
|
||||||
$this->checkRedirect = $wgLinkTitlesCheckRedirect;;
|
$this->checkRedirect = $wgLinkTitlesCheckRedirect;;
|
||||||
|
$this->specialPageReloadAfter = $wgLinkTitlesSpecialPageReloadAfter;
|
||||||
$this->enableConsoleOutput = false;
|
$this->enableConsoleOutput = false;
|
||||||
$this->enableDebugConsoleOutput = false;
|
$this->enableDebugConsoleOutput = false;
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Special extends \SpecialPage {
|
class Special extends \SpecialPage {
|
||||||
|
private $config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Announces the special page title and required user right to the parent constructor.
|
* 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
|
// users who have the 'linktitles-batch' right get to see this page (by
|
||||||
// default, this are all sysop users).
|
// default, this are all sysop users).
|
||||||
parent::__construct( 'LinkTitles', 'linktitles-batch' );
|
parent::__construct( 'LinkTitles', 'linktitles-batch' );
|
||||||
|
$this->config = new Config();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGroupName() {
|
function getGroupName() {
|
||||||
@ -94,11 +96,8 @@ class Special extends \SpecialPage {
|
|||||||
* @param OutputPage $output Output page for the special page.
|
* @param OutputPage $output Output page for the special page.
|
||||||
*/
|
*/
|
||||||
private function process( \WebRequest &$request, \OutputPage &$output) {
|
private function process( \WebRequest &$request, \OutputPage &$output) {
|
||||||
global $wgLinkTitlesTimeLimit;
|
|
||||||
global $wgLinkTitlesNamespaces;
|
|
||||||
|
|
||||||
// get our Namespaces
|
// get our Namespaces
|
||||||
$namespacesClause = str_replace( '_', ' ','(' . implode( ', ',$wgLinkTitlesNamespaces ) . ')' );
|
$namespacesClause = str_replace( '_', ' ','(' . implode( ', ',$this->config->nameSpaces ) . ')' );
|
||||||
|
|
||||||
// Start the stopwatch
|
// Start the stopwatch
|
||||||
$startTime = microtime( true );
|
$startTime = microtime( true );
|
||||||
@ -147,7 +146,7 @@ class Special extends \SpecialPage {
|
|||||||
$start += 1;
|
$start += 1;
|
||||||
|
|
||||||
// Check if the time limit is exceeded
|
// Check if the time limit is exceeded
|
||||||
if ( microtime(true)-$startTime > $wgLinkTitlesTimeLimit )
|
if ( microtime( true ) - $startTime > $config->specialPageReloadAfter )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -244,14 +243,14 @@ EOF
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Generates an HTML form and JavaScript to automatically submit the
|
* Generates an HTML form and JavaScript to automatically submit the
|
||||||
* form.
|
* form.
|
||||||
* @param $url URL to reload with a POST request.
|
* @param $url URL to reload with a POST request.
|
||||||
* @param $start Index of the next page that shall be processed.
|
* @param $start Index of the next page that shall be processed.
|
||||||
* @param $end Index of the last page to be processed.
|
* @param $end Index of the last page to be processed.
|
||||||
* @param $reloads Counter that holds the number of reloads so far.
|
* @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 ) {
|
private function getReloaderForm( $url, $start, $end, $reloads ) {
|
||||||
return
|
return
|
||||||
@ -268,16 +267,15 @@ EOF
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Adds statistics to the page when all processing is done.
|
* Adds statistics to the page when all processing is done.
|
||||||
* @param $output Output object
|
* @param $output Output object
|
||||||
* @param $start Index of the first page that was processed.
|
* @param $start Index of the first page that was processed.
|
||||||
* @param $end Index of the last processed page.
|
* @param $end Index of the last processed page.
|
||||||
* @param $reloads Number of reloads of the page.
|
* @param $reloads Number of reloads of the page.
|
||||||
* @returns undefined
|
* @return undefined
|
||||||
*/
|
*/
|
||||||
private function addCompletedInfo( &$output, $start, $end, $reloads ) {
|
private function addCompletedInfo( &$output, $start, $end, $reloads ) {
|
||||||
global $wgLinkTitlesTimeLimit;
|
|
||||||
$pagesPerReload = sprintf('%0.1f', $end / $reloads);
|
$pagesPerReload = sprintf('%0.1f', $end / $reloads);
|
||||||
$output->addWikiText(
|
$output->addWikiText(
|
||||||
<<<EOF
|
<<<EOF
|
||||||
@ -286,7 +284,7 @@ EOF
|
|||||||
|-
|
|-
|
||||||
| total number of pages: || ${end}
|
| total number of pages: || ${end}
|
||||||
|-
|
|-
|
||||||
| timeout setting [s]: || ${wgLinkTitlesTimeLimit}
|
| timeout setting [s]: || {$config->specialPageReloadAfter}
|
||||||
|-
|
|-
|
||||||
| webpage reloads: || ${reloads}
|
| webpage reloads: || ${reloads}
|
||||||
|-
|
|-
|
||||||
@ -296,10 +294,10 @@ EOF
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Counts the number of pages in a read-access wiki database ($dbr).
|
* Counts the number of pages in a read-access wiki database ($dbr).
|
||||||
* @param $dbr Read-only `Database` object.
|
* @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 ) {
|
private function countPages( &$dbr, $namespacesClause ) {
|
||||||
$res = $dbr->select(
|
$res = $dbr->select(
|
||||||
|
Reference in New Issue
Block a user