MediaWiki  1.23.14
storageTypeStats.php
Go to the documentation of this file.
1 <?php
22 require_once __DIR__ . '/../Maintenance.php';
23 
25  function execute() {
26  $dbr = wfGetDB( DB_SLAVE );
27 
28  $endId = $dbr->selectField( 'text', 'MAX(old_id)', false, __METHOD__ );
29  if ( !$endId ) {
30  echo "No text rows!\n";
31  exit( 1 );
32  }
33 
34  $binSize = intval( pow( 10, floor( log10( $endId ) ) - 3 ) );
35  if ( $binSize < 100 ) {
36  $binSize = 100;
37  }
38  echo "Using bin size of $binSize\n";
39 
40  $stats = array();
41 
42  $classSql = <<<SQL
43  IF(old_flags LIKE '%external%',
44  IF(old_text REGEXP '^DB://[[:alnum:]]+/[0-9]+/[0-9a-f]{32}$',
45  'CGZ pointer',
46  IF(old_text REGEXP '^DB://[[:alnum:]]+/[0-9]+/[0-9]{1,6}$',
47  'DHB pointer',
48  IF(old_text REGEXP '^DB://[[:alnum:]]+/[0-9]+$',
49  'simple pointer',
50  'UNKNOWN pointer'
51  )
52  )
53  ),
54  IF(old_flags LIKE '%object%',
55  TRIM('"' FROM SUBSTRING_INDEX(SUBSTRING_INDEX(old_text, ':', 3), ':', -1)),
56  '[none]'
57  )
58  )
59 SQL;
60 
61  for ( $rangeStart = 0; $rangeStart < $endId; $rangeStart += $binSize ) {
62  if ( $rangeStart / $binSize % 10 == 0 ) {
63  echo "$rangeStart\r";
64  }
65  $res = $dbr->select(
66  'text',
67  array(
68  'old_flags',
69  "$classSql AS class",
70  'COUNT(*) as count',
71  ),
72  array(
73  'old_id >= ' . intval( $rangeStart ),
74  'old_id < ' . intval( $rangeStart + $binSize )
75  ),
76  __METHOD__,
77  array( 'GROUP BY' => 'old_flags, class' )
78  );
79 
80  foreach ( $res as $row ) {
81  $flags = $row->old_flags;
82  if ( $flags === '' ) {
83  $flags = '[none]';
84  }
85  $class = $row->class;
86  $count = $row->count;
87  if ( !isset( $stats[$flags][$class] ) ) {
88  $stats[$flags][$class] = array(
89  'count' => 0,
90  'first' => $rangeStart,
91  'last' => 0
92  );
93  }
94  $entry =& $stats[$flags][$class];
95  $entry['count'] += $count;
96  $entry['last'] = max( $entry['last'], $rangeStart + $binSize );
97  unset( $entry );
98  }
99  }
100  echo "\n\n";
101 
102  $format = "%-29s %-39s %-19s %-29s\n";
103  printf( $format, "Flags", "Class", "Count", "old_id range" );
104  echo str_repeat( '-', 120 ) . "\n";
105  foreach ( $stats as $flags => $flagStats ) {
106  foreach ( $flagStats as $class => $entry ) {
107  printf( $format, $flags, $class, $entry['count'],
108  sprintf( "%-13d - %-13d", $entry['first'], $entry['last'] ) );
109  }
110  }
111  }
112 }
113 
114 $maintClass = 'StorageTypeStats';
115 require_once RUN_MAINTENANCE_IF_MAIN;
StorageTypeStats\execute
execute()
Do the actual work.
Definition: storageTypeStats.php:25
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
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
$flags
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition: hooks.txt:2124
$maintClass
$maintClass
Definition: storageTypeStats.php:97
$dbr
$dbr
Definition: testCompression.php:48
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
$count
$count
Definition: UtfNormalTest2.php:96
StorageTypeStats
Definition: storageTypeStats.php:24
DB_SLAVE
const DB_SLAVE
Definition: Defines.php:55
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
$res
$res
Definition: database.txt:21