MediaWiki
1.43.1
updateArticleCount.php
Go to the documentation of this file.
1
<?php
26
use
MediaWiki\SiteStats\SiteStatsInit
;
27
28
// @codeCoverageIgnoreStart
29
require_once __DIR__ .
'/Maintenance.php'
;
30
// @codeCoverageIgnoreEnd
31
38
class
UpdateArticleCount
extends
Maintenance {
39
40
public
function
__construct
() {
41
parent::__construct();
42
$this->addDescription(
'Count of the number of articles and update the site statistics table'
);
43
$this->addOption(
'update'
,
'Update the site_stats table with the new count'
);
44
$this->addOption(
'use-master'
,
'Count using the primary database'
);
45
}
46
47
public
function
execute
() {
48
$this->output(
"Counting articles..."
);
49
50
if
( $this->hasOption(
'use-master'
) ) {
51
$dbr = $this->getPrimaryDB();
52
}
else
{
53
$dbr = $this->getDB(
DB_REPLICA
,
'vslow'
);
54
}
55
$counter =
new
SiteStatsInit
( $dbr );
56
$result = $counter->articles();
57
58
$this->output(
"found {$result}.\n"
);
59
if
( $this->hasOption(
'update'
) ) {
60
$this->output(
"Updating site statistics table..."
);
61
$dbw = $this->getPrimaryDB();
62
$dbw->newUpdateQueryBuilder()
63
->update(
'site_stats'
)
64
->set( [
'ss_good_articles'
=> $result ] )
65
->where( [
'ss_row_id'
=> 1 ] )
66
->caller( __METHOD__ )
67
->execute();
68
$this->output(
"done.\n"
);
69
}
else
{
70
$this->output(
"To update the site statistics table, run the script "
71
.
"with the --update option.\n"
);
72
}
73
}
74
}
75
76
// @codeCoverageIgnoreStart
77
$maintClass
= UpdateArticleCount::class;
78
require_once RUN_MAINTENANCE_IF_MAIN;
79
// @codeCoverageIgnoreEnd
MediaWiki\SiteStats\SiteStatsInit
Class designed for counting of stats.
Definition
SiteStatsInit.php:32
UpdateArticleCount
Maintenance script to provide a better count of the number of articles and update the site statistics...
Definition
updateArticleCount.php:38
UpdateArticleCount\__construct
__construct()
Definition
updateArticleCount.php:40
UpdateArticleCount\execute
execute()
Definition
updateArticleCount.php:47
DB_REPLICA
const DB_REPLICA
Definition
defines.php:26
$maintClass
$maintClass
Definition
updateArticleCount.php:77
maintenance
updateArticleCount.php
Generated on Thu Apr 10 2025 18:16:03 for MediaWiki by
1.10.0