Show statistics when finished.

This commit is contained in:
Daniel Kraus
2014-06-03 16:40:37 +02:00
parent 0c9bbe0d0c
commit 6f25d469ed

View File

@ -96,13 +96,17 @@ class SpecialLinkTitles extends SpecialPage {
// If we have not reached the last page yet, produce code to reload
// the extension's special page.
if ( $start <= $end )
if ( $start < $end )
{
// Build a form with hidden values and output JavaScript code that
// immediately submits the form in order to continue the process.
$output->addHTML($this->getReloaderForm($request->getRequestURL(),
$start, $end, $reloads));
}
else // Last page has been processed
{
$this->addCompletedInfo($output, $start, $end, $reloads);
}
}
/// Processes a single page, given a $title Title object.
@ -152,7 +156,7 @@ EOF
}
/// Produces informative output in WikiText format to show while working.
private function addProgressInfo($output, $curTitle, $start, $end) {
private function addProgressInfo(&$output, $curTitle, $start, $end) {
$progress = $start / $end * 100;
$percent = sprintf("%01.1f", $progress);
@ -160,7 +164,7 @@ EOF
<<<EOF
== Processing pages... ==
The [http://www.mediawiki.org/wiki/Extension:LinkTitles LinkTitles]
extension is currently going through very page of your wiki, adding links to
extension is currently going through every page of your wiki, adding links to
existing pages as appropriate.
=== Current page: $curTitle ===
@ -203,6 +207,27 @@ EOF
;
}
/// Adds statistics to the page when all processing is done.
private function addCompletedInfo(&$output, $start, $end, $reloads) {
global $wgLinkTitlesTimeLimit;
$pagesPerReload = sprintf('%0.1f', $end / $reloads);
$output->addWikiText(
<<<EOF
== Batch processing completed! ==
{| class="wikitable"
|-
| total number of pages: || ${end}
|-
| timeout setting [s]: || ${wgLinkTitlesTimeLimit}
|-
| webpage reloads: || ${reloads}
|-
| pages scanned per reload interval: || ${pagesPerReload}
|}
EOF
);
}
/// Counts the number of pages in a read-access wiki database ($dbr).
private function countPages($dbr) {
$res = $dbr->select(