r107575 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107574‎ | r107575 | r107576 >
Date:15:27, 29 December 2011
Author:reedy
Status:ok
Tags:
Comment:
Bug 33252 - WikimediaMaintenance maintenance scripts include Maintenance.php from the wrong place

Update all scripts trying to require "Maintenance" to require "WikimediaMaintenance", and change the parent class it's extending from
Modified paths:
  • /trunk/extensions/WikimediaMaintenance/addWiki.php (modified) (history)
  • /trunk/extensions/WikimediaMaintenance/cleanupBug31576.php (modified) (history)
  • /trunk/extensions/WikimediaMaintenance/clearMessageBlobs.php (modified) (history)
  • /trunk/extensions/WikimediaMaintenance/fixJobQueueExplosion.php (modified) (history)
  • /trunk/extensions/WikimediaMaintenance/fixUsabilityPrefs.php (modified) (history)
  • /trunk/extensions/WikimediaMaintenance/fixUsabilityPrefs2.php (modified) (history)
  • /trunk/extensions/WikimediaMaintenance/jeluf.php (modified) (history)
  • /trunk/extensions/WikimediaMaintenance/listDatabases.php (modified) (history)
  • /trunk/extensions/WikimediaMaintenance/namespaceDupesWT.php (modified) (history)
  • /trunk/extensions/WikimediaMaintenance/rL.php (modified) (history)
  • /trunk/extensions/WikimediaMaintenance/rebuildInterwiki.php (modified) (history)
  • /trunk/extensions/WikimediaMaintenance/unsuppressCrossWiki.php (modified) (history)
  • /trunk/extensions/WikimediaMaintenance/x-mctest.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikimediaMaintenance/fixUsabilityPrefs2.php
@@ -1,8 +1,8 @@
22 <?php
33
4 -require( dirname( __FILE__ ) . '/../Maintenance.php' );
 4+require_once( dirname( __FILE__ ) . '/WikimediaMaintenance.php' );
55
6 -class FixUsabilityPrefs extends Maintenance {
 6+class FixUsabilityPrefs extends WikimediaMaintenance {
77 function __construct() {
88 parent::__construct();
99 }
Index: trunk/extensions/WikimediaMaintenance/jeluf.php
@@ -24,9 +24,9 @@
2525 * @ingroup Maintenance
2626 */
2727
28 -require_once( dirname(__FILE__) . '/Maintenance.php' );
 28+require_once( dirname( __FILE__ ) . '/WikimediaMaintenance.php' );
2929
30 -class RunJobs extends Maintenance {
 30+class RunJobs extends WikimediaMaintenance {
3131 public function __construct() {
3232 parent::__construct();
3333 $this->mDescription = "Run pending jobs";
@@ -34,7 +34,7 @@
3535 $this->addOption( 'type', 'Type of job to run', false, true );
3636 $this->addOption( 'procs', 'Number of processes to use', false, true );
3737 }
38 -
 38+
3939 public function memoryLimit() {
4040 // Don't eat all memory on the machine if we get a bad job.
4141 return "150M";
@@ -67,10 +67,10 @@
6868 $job = ($type == false) ?
6969 Job::pop($offset)
7070 : Job::pop_type($type);
71 -
 71+
7272 if ($job == false)
7373 break;
74 -
 74+
7575 wfWaitForSlaves( 5 );
7676 $t = microtime( true );
7777 $offset=$job->id;
Index: trunk/extensions/WikimediaMaintenance/rebuildInterwiki.php
@@ -23,7 +23,7 @@
2424 * @ingroup Maintenance
2525 * @ingroup Wikimedia
2626 */
27 -require_once( dirname( __FILE__ ) . '/WikimediaMaintenance.php' );
 27+require_once( dirname( __FILE__ ) . '/dumpInterwiki.php' );
2828
2929 class RebuildInterwiki extends DumpInterwiki {
3030
Index: trunk/extensions/WikimediaMaintenance/clearMessageBlobs.php
@@ -4,9 +4,9 @@
55 * Clear the msg_resource table on all wikis if any message file has been updated.
66 */
77
8 -require_once( dirname( __FILE__ ) .'/../Maintenance.php' );
 8+require_once( dirname( __FILE__ ) . '/WikimediaMaintenance.php' );
99
10 -class ClearMessageBlobs extends Maintenance {
 10+class ClearMessageBlobs extends WikimediaMaintenance {
1111 function __construct() {
1212 parent::__construct();
1313 }
Index: trunk/extensions/WikimediaMaintenance/listDatabases.php
@@ -1,4 +1,5 @@
2 -<? include("commandLine.inc");
 2+<?php
 3+include("commandLine.inc");
34
45 foreach ($wgLocalDatabases as $db) {
56 print "$db\n";
Index: trunk/extensions/WikimediaMaintenance/fixJobQueueExplosion.php
@@ -4,9 +4,9 @@
55 * Removes htmlCacheUpdate categorylinks jobs caused by the bug fixed in r59718.
66 */
77
8 -require_once( dirname(__FILE__).'/Maintenance.php' );
 8+require_once( dirname( __FILE__ ) . '/WikimediaMaintenance.php' );
99
10 -class FixJobQueueExplosion extends Maintenance {
 10+class FixJobQueueExplosion extends WikimediaMaintenance {
1111 public function execute() {
1212 global $IP;
1313
@@ -27,10 +27,10 @@
2828 $numBatchesDone = 0;
2929 $newId = 1;
3030 while ( true ) {
31 - $res = $dbw->select( 'job_explosion_tmp', '*',
32 - array(
 31+ $res = $dbw->select( 'job_explosion_tmp', '*',
 32+ array(
3333 'job_id > ' . $dbw->addQuotes( $start ),
34 - "NOT ( job_cmd = 'htmlCacheUpdate' AND " .
 34+ "NOT ( job_cmd = 'htmlCacheUpdate' AND " .
3535 "job_params LIKE '%s:13:\"categorylinks\"%' )"
3636 ),
3737 __METHOD__, array( 'LIMIT' => $batchSize ) );
Index: trunk/extensions/WikimediaMaintenance/cleanupBug31576.php
@@ -1,17 +1,13 @@
22 <?php
3 -$IP = getenv( 'MW_INSTALL_PATH' );
4 -if ( $IP === false ) {
5 - $IP = dirname( __FILE__ ) . '/../..';
6 -}
7 -require_once( "$IP/maintenance/Maintenance.php" );
 3+require_once( dirname( __FILE__ ) . '/WikimediaMaintenance.php' );
84
9 -class CleanupBug31576 extends Maintenance {
 5+class CleanupBug31576 extends WikimediaMaintenance {
106 public function __construct() {
117 parent::__construct();
128 $this->mDescription = "Cleans up templatelinks corruption caused by https://bugzilla.wikimedia.org/show_bug.cgi?id=31576";
139 $this->addOption( 'batchsize', 'Number of rows to process in one batch. Default: 50', false, true );
1410 }
15 -
 11+
1612 public function execute() {
1713 $this->batchsize = $this->getOption( 'batchsize', 50 );
1814 $variableIDs = MagicWord::getVariableIDs();
@@ -23,7 +19,7 @@
2420 }
2521 $this->output( "All done\n" );
2622 }
27 -
 23+
2824 public function processSynonym( $synonym ) {
2925 $dbr = wfGetDB( DB_SLAVE );
3026 $pCount = 0;
@@ -41,7 +37,7 @@
4238 // No more rows, we're done
4339 break;
4440 }
45 -
 41+
4642 $processed = array();
4743 foreach ( $res as $row ) {
4844 $vCount++;
@@ -57,7 +53,7 @@
5854 wfWaitForSlaves();
5955 }
6056 }
61 -
 57+
6258 }
6359
6460 $maintClass = "CleanupBug31576";
Index: trunk/extensions/WikimediaMaintenance/x-mctest.php
@@ -21,9 +21,9 @@
2222 * @ingroup Maintenance
2323 */
2424
25 -require_once( dirname(__FILE__) . '/Maintenance.php' );
 25+require_once( dirname( __FILE__ ) . '/WikimediaMaintenance.php' );
2626
27 -class mcTest extends Maintenance {
 27+class mcTest extends WikimediaMaintenance {
2828 public function __construct() {
2929 parent::__construct();
3030 $this->mDescription = "Makes several 'set', 'incr' and 'get' requests on every"
@@ -65,7 +65,7 @@
6666 }
6767 }
6868 $exectime = $this->microtime_float() - $time_start;
69 -
 69+
7070 $this->output( "set: $set incr: $incr get: $get time: $exectime\n" );
7171 }
7272 }
Index: trunk/extensions/WikimediaMaintenance/namespaceDupesWT.php
@@ -23,9 +23,15 @@
2424 * @ingroup Maintenance
2525 */
2626
27 -require_once( dirname(__FILE__) . '/Maintenance.php' );
 27+require_once( dirname( __FILE__ ) . '/WikimediaMaintenance.php' );
2828
29 -class NamespaceConflictChecker extends Maintenance {
 29+class NamespaceConflictChecker extends WikimediaMaintenance {
 30+
 31+ /**
 32+ * @var DatabaseBase
 33+ */
 34+ protected $db;
 35+
3036 public function __construct() {
3137 parent::__construct();
3238 $this->mDescription = "";
@@ -52,7 +58,7 @@
5359 } else {
5460 $retval = $this->checkAll( $fix, $suffix );
5561 }
56 -
 62+
5763 if( $retval ) {
5864 $this->output( "\nLooks good!\n" );
5965 } else {
@@ -68,9 +74,9 @@
6975 private function checkAll( $fix, $suffix = '' ) {
7076 global $wgContLang, $wgNamespaceAliases, $wgCanonicalNamespaceNames;
7177 global $wgCapitalLinks;
72 -
 78+
7379 $spaces = array();
74 -
 80+
7581 // List interwikis first, so they'll be overridden
7682 // by any conflicting local namespaces.
7783 foreach( $this->getInterwikiList() as $prefix ) {
@@ -96,7 +102,7 @@
97103 foreach( $wgContLang->getNamespaceAliases() as $name => $ns ) {
98104 $spaces[$name] = $ns;
99105 }
100 -
 106+
101107 // We'll need to check for lowercase keys as well,
102108 // since we're doing case-sensitive searches in the db.
103109 foreach( $spaces as $name => $ns ) {
@@ -119,10 +125,10 @@
120126 }
121127 }
122128 }
123 -
 129+
124130 ksort( $spaces );
125131 asort( $spaces );
126 -
 132+
127133 $ok = true;
128134 foreach( $spaces as $name => $ns ) {
129135 $ok = $this->checkNamespace( $ns, $name, $fix, $suffix ) && $ok;
@@ -169,7 +175,7 @@
170176 }
171177 return $ok;
172178 }
173 -
 179+
174180 /**
175181 * @todo: do this for reals
176182 */
@@ -196,7 +202,7 @@
197203 // An interwiki; try an alternate encoding with '-' for ':'
198204 $titleSql = $this->db->buildConcat( array( "'$prefix-'", $titleSql ) );
199205 }
200 -
 206+
201207 $sql = "SELECT {$page}_id AS id,
202208 {$page}_title AS oldtitle,
203209 $encNamespace + {$page}_namespace AS namespace,
@@ -212,7 +218,6 @@
213219 foreach( $result as $row ) {
214220 $set[] = $row;
215221 }
216 - $this->db->freeResult( $result );
217222
218223 return $set;
219224 }
@@ -253,7 +258,7 @@
254259 /**
255260 * Resolve any conflicts
256261 * @param $row Row from the page table to fix
257 - * @param $resolveable bool
 262+ * @param $resolveable bool
258263 * @param $suffix String Suffix to append to the fixed page
259264 */
260265 private function resolveConflict( $row, $resolvable, $suffix ) {
@@ -267,9 +272,10 @@
268273 $this->output( "... !!! invalid title\n" );
269274 return false;
270275 }
271 - if ( $id = $title->getArticleId() ) {
 276+ $id = $title->getArticleId();
 277+ if ( $id ) {
272278 $this->output( "... *** page exists with ID $id ***\n" );
273 - } else {
 279+ } else {
274280 break;
275281 }
276282 }
Index: trunk/extensions/WikimediaMaintenance/fixUsabilityPrefs.php
@@ -1,8 +1,8 @@
22 <?php
33
4 -require( dirname( __FILE__ ) . '/../Maintenance.php' );
 4+require_once( dirname( __FILE__ ) . '/WikimediaMaintenance.php' );
55
6 -class FixUsabilityPrefs extends Maintenance {
 6+class FixUsabilityPrefs extends WikimediaMaintenance {
77 function __construct() {
88 parent::__construct();
99 }
Index: trunk/extensions/WikimediaMaintenance/addWiki.php
@@ -28,7 +28,7 @@
2929 */
3030 require_once( dirname( __FILE__ ) . '/WikimediaMaintenance.php' );
3131
32 -class AddWiki extends Maintenance {
 32+class AddWiki extends WikimediaMaintenance {
3333 public function __construct() {
3434 global $wgNoDBParam;
3535
Index: trunk/extensions/WikimediaMaintenance/rL.php
@@ -18,9 +18,9 @@
1919 * @ingroup Maintenance
2020 */
2121
22 -require_once( dirname(__FILE__) . '/Maintenance.php' );
 22+require_once( dirname( __FILE__ ) . '/WikimediaMaintenance.php' );
2323
24 -class RefreshLinks extends Maintenance {
 24+class RefreshLinks extends WikimediaMaintenance {
2525 public function __construct() {
2626 parent::__construct();
2727 $this->mDescription = "Refresh link tables";
Index: trunk/extensions/WikimediaMaintenance/unsuppressCrossWiki.php
@@ -1,8 +1,8 @@
22 <?php
3 -
4 -require_once( dirname( __FILE__ ) . '/Maintenance.php' );
53
6 -class unsuppressCrossWiki extends Maintenance {
 4+require_once( dirname( __FILE__ ) . '/WikimediaMaintenance.php' );
 5+
 6+class unsuppressCrossWiki extends WikimediaMaintenance {
77 public function __construct() {
88 parent::__construct();
99 $this->mDescription = "Show number of jobs waiting in master database";
@@ -24,14 +24,14 @@
2525 # Get local ID like $user->localUserData( $wiki ) does
2626 $localUserId = $dbw->selectField( 'user', 'user_id',
2727 array( 'user_name' => $userName ), __METHOD__ );
28 -
 28+
2929 $delUserBit = Revision::DELETED_USER;
3030 $hiddenCount = $dbw->selectField( 'revision', 'COUNT(*)',
3131 array( 'rev_user' => $localUserId, "rev_deleted & $delUserBit != 0" ), __METHOD__ );
3232 echo "$hiddenCount edits have the username hidden on \"$wiki\"\n";
3333 # Unsuppress username on edits
3434 if ( $hiddenCount > 0 ) {
35 - echo "Unsuppressed edits of attached account (local id $localUserId) on \"$wiki\"...";
 35+ echo "Unsuppressed edits of attached account (local id $localUserId) on \"$wiki\"...";
3636 IPBlockForm::unsuppressUserName( $userName, $localUserId, $dbw );
3737 echo "done!\n\n";
3838 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r107576Bug 33252 - WikimediaMaintenance maintenance scripts include Maintenance.php ...reedy15:35, 29 December 2011
r107577Bug 33252 - WikimediaMaintenance maintenance scripts include Maintenance.php ...reedy15:38, 29 December 2011

Status & tagging log