MediaWiki  1.23.14
orphanStats.php
Go to the documentation of this file.
1 <?php
24 require_once __DIR__ . '/../Maintenance.php';
25 
32 class OrphanStats extends Maintenance {
33  public function __construct() {
34  parent::__construct();
35  $this->mDescription = "how some statistics on the blob_orphans table, created with trackBlobs.php";
36  }
37 
38  protected function &getDB( $cluster, $groups = array(), $wiki = false ) {
39  $lb = wfGetLBFactory()->getExternalLB( $cluster );
40  return $lb->getConnection( DB_SLAVE );
41  }
42 
43  public function execute() {
44  $dbr = wfGetDB( DB_SLAVE );
45  if ( !$dbr->tableExists( 'blob_orphans' ) ) {
46  $this->error( "blob_orphans doesn't seem to exist, need to run trackBlobs.php first", true );
47  }
48  $res = $dbr->select( 'blob_orphans', '*', false, __METHOD__ );
49 
50  $num = 0;
51  $totalSize = 0;
52  $hashes = array();
53  $maxSize = 0;
54 
55  foreach ( $res as $boRow ) {
56  $extDB = $this->getDB( $boRow->bo_cluster );
57  $blobRow = $extDB->selectRow( 'blobs', '*', array( 'blob_id' => $boRow->bo_blob_id ), __METHOD__ );
58 
59  $num++;
60  $size = strlen( $blobRow->blob_text );
61  $totalSize += $size;
62  $hashes[ sha1( $blobRow->blob_text ) ] = true;
63  $maxSize = max( $size, $maxSize );
64  }
65  unset( $res );
66 
67  $this->output( "Number of orphans: $num\n" );
68  if ( $num > 0 ) {
69  $this->output( "Average size: " . round( $totalSize / $num, 0 ) . " bytes\n" .
70  "Max size: $maxSize\n" .
71  "Number of unique texts: " . count( $hashes ) . "\n" );
72  }
73  }
74 }
75 
76 $maintClass = "OrphanStats";
77 require_once RUN_MAINTENANCE_IF_MAIN;
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
OrphanStats\getDB
& getDB( $cluster, $groups=array(), $wiki=false)
Returns a database to be used by current maintenance script.
Definition: orphanStats.php:38
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3714
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
OrphanStats\__construct
__construct()
Default constructor.
Definition: orphanStats.php:33
$dbr
$dbr
Definition: testCompression.php:48
$lb
if( $wgAPIRequestLog) $lb
Definition: api.php:126
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
OrphanStats
Maintenance script that shows some statistics on the blob_orphans table, created with trackBlobs....
Definition: orphanStats.php:32
$size
$size
Definition: RandomTest.php:75
DB_SLAVE
const DB_SLAVE
Definition: Defines.php:55
wfGetLBFactory
& wfGetLBFactory()
Get the load balancer factory object.
Definition: GlobalFunctions.php:3733
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Maintenance\error
error( $err, $die=0)
Throw an error to the user.
Definition: Maintenance.php:333
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:314
$hashes
$hashes
Definition: testCompression.php:62
$res
$res
Definition: database.txt:21
OrphanStats\execute
execute()
Do the actual work.
Definition: orphanStats.php:43
$maintClass
$maintClass
Definition: orphanStats.php:76