Index: trunk/phase3/maintenance/nextJobDB.php |
— | — | @@ -17,6 +17,7 @@ |
18 | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
19 | 19 | * http://www.gnu.org/copyleft/gpl.html |
20 | 20 | * |
| 21 | + * @todo Make this work on PostgreSQL and maybe other database servers |
21 | 22 | * @ingroup Maintenance |
22 | 23 | */ |
23 | 24 | |
— | — | @@ -65,18 +66,23 @@ |
66 | 67 | foreach ( $dbsByMaster as $master => $dbs ) { |
67 | 68 | $dbConn = wfGetDB( DB_MASTER, array(), $dbs[0] ); |
68 | 69 | $stype = $dbConn->addQuotes($type); |
69 | | - $jobTable = $dbConn->tableName( 'job' ); |
| 70 | + |
70 | 71 | |
71 | 72 | # Padding row for MySQL bug |
72 | 73 | $sql = "(SELECT '-------------------------------------------' as db)"; |
73 | | - foreach ( $dbs as $dbName ) { |
| 74 | + foreach ( $dbs as $wikiId ) { |
74 | 75 | if ( $sql != '' ) { |
75 | 76 | $sql .= ' UNION '; |
76 | 77 | } |
77 | | - if ($type === false) |
78 | | - $sql .= "(SELECT '$dbName' as db FROM `$dbName`.$jobTable LIMIT 1)"; |
| 78 | + |
| 79 | + list( $dbName, $tablePrefix ) = wfSplitWikiID( $wikiId ); |
| 80 | + $dbConn->tablePrefix( $tablePrefix ); |
| 81 | + $jobTable = $dbConn->tableName( 'job' ); |
| 82 | + |
| 83 | + if ( $type === false ) |
| 84 | + $sql .= "(SELECT '$wikiId' as db FROM $dbName.$jobTable LIMIT 1)"; |
79 | 85 | else |
80 | | - $sql .= "(SELECT '$dbName' as db FROM `$dbName`.$jobTable WHERE job_cmd=$stype LIMIT 1)"; |
| 86 | + $sql .= "(SELECT '$wikiId' as db FROM $dbName.$jobTable WHERE job_cmd=$stype LIMIT 1)"; |
81 | 87 | } |
82 | 88 | $res = $dbConn->query( $sql, __METHOD__ ); |
83 | 89 | $first = true; |
Index: trunk/phase3/maintenance/cleanupSpam.php |
— | — | @@ -44,20 +44,19 @@ |
45 | 45 | if ( !$like ) { |
46 | 46 | $this->error( "Not a valid hostname specification: $spec", true ); |
47 | 47 | } |
48 | | - |
49 | | - $dbr = wfGetDB( DB_SLAVE ); |
50 | 48 | |
51 | 49 | if ( $this->hasOption('all') ) { |
52 | 50 | // Clean up spam on all wikis |
53 | | - $dbr = wfGetDB( DB_SLAVE ); |
54 | | - $this->output( "Finding spam on " . count($wgLocalDatabases) . " wikis\n" ); |
| 51 | + $this->output( "Finding spam on " . count( $wgLocalDatabases ) . " wikis\n" ); |
55 | 52 | $found = false; |
56 | | - foreach ( $wgLocalDatabases as $db ) { |
57 | | - $count = $dbr->selectField( "`$db`.externallinks", 'COUNT(*)', |
| 53 | + foreach ( $wgLocalDatabases as $wikiID ) { |
| 54 | + $dbr = wfGetDB( DB_SLAVE, array(), $wikiID ); |
| 55 | + |
| 56 | + $count = $dbr->selectField( 'externallinks', 'COUNT(*)', |
58 | 57 | array( 'el_index LIKE ' . $dbr->addQuotes( $like ) ), __METHOD__ ); |
59 | 58 | if ( $count ) { |
60 | 59 | $found = true; |
61 | | - passthru( "php cleanupSpam.php $db $spec | sed s/^/$db: /" ); |
| 60 | + passthru( "php cleanupSpam.php --wiki='$wikiID' $spec | sed 's/^/$wikiID: /'" ); |
62 | 61 | } |
63 | 62 | } |
64 | 63 | if ( $found ) { |
— | — | @@ -67,11 +66,13 @@ |
68 | 67 | } |
69 | 68 | } else { |
70 | 69 | // Clean up spam on this wiki |
| 70 | + |
| 71 | + $dbr = wfGetDB( DB_SLAVE ); |
71 | 72 | $res = $dbr->select( 'externallinks', array( 'DISTINCT el_from' ), |
72 | 73 | array( 'el_index LIKE ' . $dbr->addQuotes( $like ) ), __METHOD__ ); |
73 | 74 | $count = $dbr->numRows( $res ); |
74 | 75 | $this->output( "Found $count articles containing $spec\n" ); |
75 | | - while ( $row = $dbr->fetchObject( $res ) ) { |
| 76 | + foreach ( $res as $row ) { |
76 | 77 | $this->cleanupArticle( $row->el_from, $spec ); |
77 | 78 | } |
78 | 79 | if ( $count ) { |