Job::pop() may occasionally return false when there are actually more jobs remaining...
authorTim Starling <tstarling@users.mediawiki.org>
Tue, 28 Feb 2006 05:24:52 +0000 (05:24 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Tue, 28 Feb 2006 05:24:52 +0000 (05:24 +0000)
maintenance/archives/patch-profiling.sql
maintenance/cleanupSpam.php
maintenance/clear_stats.php
maintenance/commandLine.inc
maintenance/ourusers.php
maintenance/runJobs.php

index 1b22778..2b1f08a 100644 (file)
@@ -1,10 +1,11 @@
 -- profiling table
 -- This is optional
 
-CREATE TABLE /*$wgDBprefix*/profiling (
-       pf_count integer not null default 0,
-       pf_time float not null default 0,
-       pf_name varchar(255) not null default '',
-       UNIQUE KEY pf_name (pf_name)
-);
-       
+CREATE TABLE profiling (
+  pf_count int(11) NOT NULL default '0',
+  pf_time float NOT NULL default '0',
+  pf_name varchar(255) NOT NULL default '',
+  pf_server varchar(30) NOT NULL default '',
+  UNIQUE KEY pf_name_server (pf_name,pf_server)
+) TYPE=HEAP;
+
index 01b1f63..65d6bc4 100644 (file)
@@ -53,6 +53,9 @@ function cleanupArticle( $id, $domain ) {
 }
 //------------------------------------------------------------------------------
 
+
+
+
 $username = wfMsg( 'spambot_username' );
 $fname = $username;
 $wgUser = User::newFromName( $username );
@@ -74,15 +77,36 @@ if ( !$like ) {
 
 $dbr =& wfGetDB( DB_SLAVE );
 
-$res = $dbr->select( 'externallinks', array( 'el_from' ), 
-       array( 'el_index LIKE ' . $dbr->addQuotes( $like ) ), $fname );
-$count = $dbr->numRows( $res );
-print "Found $count articles containing $spec\n";
-while ( $row = $dbr->fetchObject( $res ) ) {
-       cleanupArticle( $row->el_from, $spec );
-}
-if ( $count ) {
-       print "Done\n";
+if ( $options['all'] ) {
+       // Clean up spam on all wikis
+       $dbr =& wfGetDB( DB_SLAVE );
+       print "Finding spam on " . count($wgLocalDatabases) . " wikis\n";
+       $found = false;
+       foreach ( $wgLocalDatabases as $db ) {
+               $count = $dbr->selectField( "`$db`.externallinks", 'COUNT(*)', 
+                       array( 'el_index LIKE ' . $dbr->addQuotes( $like ) ), $fname );
+               if ( $count ) {
+                       $found = true;
+                       passthru( "php cleanupSpam.php $db $spec | sed s/^/$db:  /" );
+               }
+       }
+       if ( $found ) {
+               print "All done\n";
+       } else {
+               print "None found\n";
+       }
+} else {
+       // Clean up spam on this wiki
+       $res = $dbr->select( 'externallinks', array( 'DISTINCT el_from' ), 
+               array( 'el_index LIKE ' . $dbr->addQuotes( $like ) ), $fname );
+       $count = $dbr->numRows( $res );
+       print "Found $count articles containing $spec\n";
+       while ( $row = $dbr->fetchObject( $res ) ) {
+               cleanupArticle( $row->el_from, $spec );
+       }
+       if ( $count ) {
+               print "Done\n";
+       }
 }
 
 ?>
index 278c609..00cfd0c 100644 (file)
@@ -2,13 +2,19 @@
 require_once('commandLine.inc');
 
 foreach ( $wgLocalDatabases as $db ) {
+       noisyDelete("$db:stats:request_with_session");
+       noisyDelete("$db:stats:request_without_session");
        noisyDelete("$db:stats:pcache_hit");
        noisyDelete("$db:stats:pcache_miss_invalid");
        noisyDelete("$db:stats:pcache_miss_expired");
        noisyDelete("$db:stats:pcache_miss_absent");
+       noisyDelete("$db:stats:pcache_miss_stub");
        noisyDelete("$db:stats:image_cache_hit");
        noisyDelete("$db:stats:image_cache_miss");
        noisyDelete("$db:stats:image_cache_update");
+       noisyDelete("$db:stats:diff_cache_hit");
+       noisyDelete("$db:stats:diff_cache_miss");
+       noisyDelete("$db:stats:diff_uncacheable");
 }
 
 function noisyDelete( $key ) {
index c213a2e..f5b28d6 100644 (file)
@@ -28,7 +28,7 @@ $optionsWithArgs[] = 'conf'; # For specifying the location of LocalSettings.php
 $self = array_shift( $argv );
 $self = __FILE__;
 $IP = realpath( dirname( $self ) . '/..' );
-chdir( $IP );
+#chdir( $IP );
 
 $options = array();
 $args = array();
@@ -91,10 +91,11 @@ if (!isset( $wgUseNormalUser ) ) {
 
 if ( file_exists( '/home/wikipedia/common/langlist' ) ) {
        $wgWikiFarm = true;
-       require_once( $IP.'/includes/SiteConfiguration.php' );
+       $cluster = trim( file_get_contents( '/etc/cluster' ) );
+       require_once( "$IP/includes/SiteConfiguration.php" );
 
-       # Get $conf
-       require( $IP.'/InitialiseSettings.php' );
+       # Get $wgConf
+       require( "$IP/wgConf.php" );
 
        if ( empty( $wgNoDBParam ) ) {
                # Check if we were passed a db name
@@ -130,15 +131,17 @@ if ( file_exists( '/home/wikipedia/common/langlist' ) ) {
        $DP = $IP;
        ini_set( 'include_path', ".:$IP:$IP/includes:$IP/languages:$IP/maintenance" );
 
+       require_once( $IP.'/includes/ProfilerStub.php' );
        require_once( $IP.'/includes/Defines.php' );
        require_once( $IP.'/CommonSettings.php' );
 
+       $bin = '/home/wikipedia/bin';
        if ( $wgUseRootUser ) {
                $wgDBuser = $wgDBadminuser = 'root';
-               $wgDBpassword = $wgDBadminpassword = trim(`mysql_root_pass`);
+               $wgDBpassword = $wgDBadminpassword = trim(`$bin/mysql_root_pass`);
        } elseif ( !$wgUseNormalUser ) {
                $wgDBuser = $wgDBadminuser = 'wikiadmin';
-               $wgDBpassword = $wgDBadminpassword = trim(`wikiadmin_pass`);
+               $wgDBpassword = $wgDBadminpassword = trim(`$bin/wikiadmin_pass`);
        }
 } else {
        $wgWikiFarm = false;
@@ -155,6 +158,7 @@ if ( file_exists( '/home/wikipedia/common/langlist' ) ) {
        }
        $wgCommandLineMode = true;
        $DP = $IP;
+       require_once( $IP.'/includes/ProfilerStub.php' );
        require_once( $IP.'/includes/Defines.php' );
        require_once( $settingsFile );
        ini_set( 'include_path', ".$sep$IP$sep$IP/includes$sep$IP/languages$sep$IP/maintenance" );
index 56464cd..241e153 100644 (file)
@@ -45,6 +45,7 @@ if ( @$argv[1] == 'yaseo' ) {
                '207.142.131.197',
                '207.142.131.198',
                '207.142.131.199',
+               '207.142.131.221',
                '207.142.131.226',
                '207.142.131.227',
                '207.142.131.228',
@@ -81,6 +82,7 @@ foreach( $hosts as $host ) {
        print "--\n-- $host\n--\n\n-- wikiuser\n\n";
        print "GRANT REPLICATION CLIENT,PROCESS ON *.* TO 'wikiuser'@'$host' IDENTIFIED BY '$wikiuser_pass';\n";
        print "GRANT ALL PRIVILEGES ON `boardvote`.* TO 'wikiuser'@'$host' IDENTIFIED BY '$wikiuser_pass';\n";
+       print "GRANT ALL PRIVILEGES ON `boardvote2005`.* TO 'wikiuser'@'$host' IDENTIFIED BY '$wikiuser_pass';\n";
        foreach( $databases as $db ) {
                print "GRANT SELECT, INSERT, UPDATE, DELETE ON `$db`.* TO 'wikiuser'@'$host' IDENTIFIED BY '$wikiuser_pass';\n";
        }
@@ -110,6 +112,7 @@ EOS;
        print "\n-- wikiadmin\n\n";
        print "GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'wikiadmin'@'$host' IDENTIFIED BY '$wikiadmin_pass';\n";
        print "GRANT ALL PRIVILEGES ON `boardvote`.* TO wikiadmin@'$host' IDENTIFIED BY '$wikiadmin_pass';\n";
+       print "GRANT ALL PRIVILEGES ON `boardvote2005`.* TO wikiadmin@'$host' IDENTIFIED BY '$wikiadmin_pass';\n";
        foreach ( $databases as $db ) {
                print "GRANT ALL PRIVILEGES ON `$db`.* TO wikiadmin@'$host' IDENTIFIED BY '$wikiadmin_pass';\n";
        }
index 799b9fa..3b63daa 100644 (file)
@@ -7,11 +7,13 @@ require_once( "$IP/includes/FakeTitle.php" );
 // Trigger errors on inappropriate use of $wgTitle
 $wgTitle = new FakeTitle;
 
-while ( false != ($job = Job::pop()) ) {
-       wfWaitForSlaves( 5 );
-       print $job->toString() . "\n";
-       if ( !$job->run() ) {
-               print "Error: {$job->error}\n";
+$dbw =& wfGetDB( DB_MASTER );
+while ( $dbw->selectField( 'job', 'count(*)', '', 'runJobs.php' ) ) {
+       while ( false != ($job = Job::pop()) ) {
+               wfWaitForSlaves( 5 );
+               print $job->id . "  " . $job->toString() . "\n";
+               if ( !$job->run() ) {
+                       print "Error: {$job->error}\n";
+               }
        }
 }
-