Index: branches/maintenance-work/maintenance/stats.php |
— | — | @@ -26,9 +26,9 @@ |
27 | 27 | $this->error( "You either have no stats or memcached isn't running. Aborting.\n", true ); |
28 | 28 | } |
29 | 29 | $this->output( "Requests\n" ); |
30 | | - $this->output( sprintf( "with session: %-10d %6.2f%%\n", $session, $session/$total*100 ); |
31 | | - $this->output( sprintf( "without session: %-10d %6.2f%%\n", $noSession, $noSession/$total*100 ); |
32 | | - $this->output( sprintf( "total: %-10d %6.2f%%\n", $total, 100 ); |
| 30 | + $this->output( sprintf( "with session: %-10d %6.2f%%\n", $session, $session/$total*100 ) ); |
| 31 | + $this->output( sprintf( "without session: %-10d %6.2f%%\n", $noSession, $noSession/$total*100 ) ); |
| 32 | + $this->output( sprintf( "total: %-10d %6.2f%%\n", $total, 100 ) ); |
33 | 33 | |
34 | 34 | |
35 | 35 | $this->output( "\nParser cache\n" ); |
— | — | @@ -59,9 +59,9 @@ |
60 | 60 | $uncacheable = intval($wgMemc->get(wfMemcKey('stats','diff_uncacheable'))); |
61 | 61 | $total = $hits + $misses + $uncacheable; |
62 | 62 | $this->output("\nDiff cache\n"); |
63 | | - $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits/$total*100 ); |
64 | | - $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses/$total*100 ); |
65 | | - $this->output( sprintf( "uncacheable: %-10d %6.2f%%\n", $uncacheable, $uncacheable/$total*100 ); |
| 63 | + $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits/$total*100 ) ); |
| 64 | + $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses/$total*100 ) ); |
| 65 | + $this->output( sprintf( "uncacheable: %-10d %6.2f%%\n", $uncacheable, $uncacheable/$total*100 ) ); |
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
Index: branches/maintenance-work/maintenance/updateArticleCount.php |
— | — | @@ -15,14 +15,14 @@ |
16 | 16 | private $namespaces; |
17 | 17 | |
18 | 18 | public function __construct() { |
19 | | - global $wgContentNamespaces; |
20 | 19 | parent::__construct(); |
21 | 20 | $this->mDescription = "Count of the number of articles and update the site statistics table"; |
22 | 21 | $this->addParam( 'update', 'Update the site_stats table with the new count' ); |
23 | | - $this->namespaces = $wgContentNamespaces; |
24 | 22 | } |
25 | 23 | |
26 | 24 | public function execute() { |
| 25 | + global $wgContentNamespaces; |
| 26 | + $this->namespaces = $wgContentNamespaces; |
27 | 27 | $this->output( "Counting articles..." ); |
28 | 28 | $result = $this->count(); |
29 | 29 | |
Index: branches/maintenance-work/maintenance/changePassword.php |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | parent::__construct(); |
19 | 19 | $this->addParam( "user", "The username to operate on", true, true ); |
20 | 20 | $this->addParam( "password", "The password to use", true, true ); |
21 | | - $this->mDescription = "Change a user's password." |
| 21 | + $this->mDescription = "Change a user's password"; |
22 | 22 | } |
23 | 23 | |
24 | 24 | public function execute() { |
Index: branches/maintenance-work/maintenance/purgeOldText.php |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | public function __construct() { |
14 | 14 | parent::__construct(); |
15 | 15 | $this->mDescription = "Purge old text records from the database"; |
16 | | - $this->addOption( 'purge', 'Performs the deletion' ); |
| 16 | + $this->addParam( 'purge', 'Performs the deletion' ); |
17 | 17 | } |
18 | 18 | |
19 | 19 | public function execute() { |
Index: branches/maintenance-work/maintenance/checkImages.php |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | $file = RepoGroup::singleton()->getLocalRepo()->newFileFromRow( $row ); |
30 | 30 | $path = $file->getPath(); |
31 | 31 | if ( !$path ) { |
32 | | - $this->output( "{$row->img_name}: not locally accessible\n"; |
| 32 | + $this->output( "{$row->img_name}: not locally accessible\n" ); |
33 | 33 | continue; |
34 | 34 | } |
35 | 35 | $stat = @stat( $file->getPath() ); |
Index: branches/maintenance-work/maintenance/nextJobDB.php |
— | — | @@ -16,16 +16,16 @@ |
17 | 17 | } |
18 | 18 | public function execute() { |
19 | 19 | global $wgMemc; |
20 | | - $type = $this->getParam( 'type', false ); |
| 20 | + $type = $this->getOption( 'type', false ); |
21 | 21 | $mckey = $type === false |
22 | 22 | ? "jobqueue:dbs" |
23 | 23 | : "jobqueue:dbs:$type"; |
24 | | - $pendingDBs = $wgMemcKey->get( $mckey ); |
| 24 | + $pendingDBs = $wgMemc->get( $mckey ); |
25 | 25 | |
26 | 26 | # If we didn't get it from the cache |
27 | 27 | if( !$pendingDBs ) { |
28 | 28 | $pendingDBs = $this->getPendingDbs( $type ); |
29 | | - $wgMemc->get( $mckey, $pendingDBs, 300 ) |
| 29 | + $wgMemc->get( $mckey, $pendingDBs, 300 ); |
30 | 30 | } |
31 | 31 | # If we've got a pending job in a db, display it. |
32 | 32 | if ( $pendingDBs ) { |
— | — | @@ -39,6 +39,7 @@ |
40 | 40 | * @return array |
41 | 41 | */ |
42 | 42 | private function getPendingDbs( $type ) { |
| 43 | + global $wgLocalDatabases; |
43 | 44 | $pendingDBs = array(); |
44 | 45 | # Cross-reference DBs by master DB server |
45 | 46 | $dbsByMaster = array(); |
Index: branches/maintenance-work/maintenance/renameDbPrefix.php |
— | — | @@ -38,7 +38,7 @@ |
39 | 39 | $this->error( "Invalid prefix!\n", true ); |
40 | 40 | } |
41 | 41 | if( $old === $new ) { |
42 | | - $this->( "Same prefix. Nothing to rename!\n", true ); |
| 42 | + $this->output( "Same prefix. Nothing to rename!\n", true ); |
43 | 43 | } |
44 | 44 | |
45 | 45 | $this->output( "Renaming DB prefix for tables of $wgDBname from '$old' to '$new'\n" ); |
Index: branches/maintenance-work/maintenance/benchmarkPurge.php |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | |
14 | 14 | public function __construct() { |
15 | 15 | parent::__construct(); |
16 | | - $this->addParams( "count", "How many URLs to feed to Squid for purging", false, true ); |
| 16 | + $this->addParam( "count", "How many URLs to feed to Squid for purging", false, true ); |
17 | 17 | $this->mDescription = "Benchmark the Squid purge functions."; |
18 | 18 | } |
19 | 19 | |
Index: branches/maintenance-work/maintenance/rebuildtextindex.php |
— | — | @@ -11,23 +11,82 @@ |
12 | 12 | * @ingroup Maintenance |
13 | 13 | */ |
14 | 14 | |
15 | | -/** */ |
16 | | -require_once( "commandLine.inc" ); |
17 | | -require_once( "rebuildtextindex.inc" ); |
| 15 | +require_once( "Maintenance.php" ); |
18 | 16 | |
19 | | -$database = wfGetDB( DB_MASTER ); |
20 | | -if( !$database instanceof DatabaseMysql ) { |
21 | | - print "This script is only for MySQL.\n"; |
22 | | - exit(1); |
23 | | -} |
| 17 | +class RebuildTextIndex extends Maintenance { |
24 | 18 | |
25 | | -$wgTitle = Title::newFromText( "Rebuild text index script" ); |
| 19 | + const RTI_CHUNK_SIZE = 500; |
26 | 20 | |
27 | | -dropTextIndex( $database ); |
28 | | -rebuildTextIndex( $database ); |
29 | | -createTextIndex( $database ); |
| 21 | + public function __construct() { |
| 22 | + parent::__construct(); |
| 23 | + $this->mDescription = "Rebuild search index table from scratch"; |
| 24 | + } |
30 | 25 | |
31 | | -print "Done.\n"; |
32 | | -exit(0); |
| 26 | + public function execute() { |
| 27 | + global $wgTitle; |
| 28 | + |
| 29 | + // Only do this for MySQL |
| 30 | + $database = wfGetDB( DB_MASTER ); |
| 31 | + if( !$database instanceof DatabaseMysql ) { |
| 32 | + $this->error( "This script is only for MySQL.\n", true ); |
| 33 | + } |
33 | 34 | |
| 35 | + $wgTitle = Title::newFromText( "Rebuild text index script" ); |
| 36 | + |
| 37 | + $this->dropTextIndex( $database ); |
| 38 | + $this->rebuildTextIndex( $database ); |
| 39 | + $this->createTextIndex( $database ); |
| 40 | + |
| 41 | + $this->output( "Done.\n" ); |
| 42 | + } |
| 43 | + |
| 44 | + private function dropTextIndex( &$database ) { |
| 45 | + $searchindex = $database->tableName( 'searchindex' ); |
| 46 | + if ( $database->indexExists( "searchindex", "si_title" ) ) { |
| 47 | + $this->output( "Dropping index...\n" ); |
| 48 | + $sql = "ALTER TABLE $searchindex DROP INDEX si_title, DROP INDEX si_text"; |
| 49 | + $database->query($sql, "dropTextIndex" ); |
| 50 | + } |
| 51 | + } |
34 | 52 | |
| 53 | + private function createTextIndex( &$database ) { |
| 54 | + $searchindex = $database->tableName( 'searchindex' ); |
| 55 | + $this->output( "\nRebuild the index...\n" ); |
| 56 | + $sql = "ALTER TABLE $searchindex ADD FULLTEXT si_title (si_title), " . |
| 57 | + "ADD FULLTEXT si_text (si_text)"; |
| 58 | + $database->query($sql, "createTextIndex" ); |
| 59 | + } |
| 60 | + |
| 61 | + private function rebuildTextIndex( &$database ) { |
| 62 | + list ($page, $revision, $text, $searchindex) = $database->tableNamesN( 'page', 'revision', 'text', 'searchindex' ); |
| 63 | + |
| 64 | + $sql = "SELECT MAX(page_id) AS count FROM $page"; |
| 65 | + $res = $database->query($sql, "rebuildTextIndex" ); |
| 66 | + $s = $database->fetchObject($res); |
| 67 | + $count = $s->count; |
| 68 | + $this->output( "Rebuilding index fields for {$count} pages...\n" ); |
| 69 | + $n = 0; |
| 70 | + |
| 71 | + while ( $n < $count ) { |
| 72 | + $this->output( $n . "\n" ); |
| 73 | + $end = $n + self::RTI_CHUNK_SIZE - 1; |
| 74 | + $sql = "SELECT page_id, page_namespace, page_title, old_flags, old_text |
| 75 | + FROM $page, $revision, $text |
| 76 | + WHERE page_id BETWEEN $n AND $end |
| 77 | + AND page_latest=rev_id |
| 78 | + AND rev_text_id=old_id"; |
| 79 | + $res = $database->query($sql, "rebuildTextIndex" ); |
| 80 | + |
| 81 | + while( $s = $database->fetchObject($res) ) { |
| 82 | + $revtext = Revision::getRevisionText( $s ); |
| 83 | + $u = new SearchUpdate( $s->page_id, $s->page_title, $revtext ); |
| 84 | + $u->doUpdate(); |
| 85 | + } |
| 86 | + $database->freeResult( $res ); |
| 87 | + $n += self::RTI_CHUNK_SIZE; |
| 88 | + } |
| 89 | + } |
| 90 | +} |
| 91 | + |
| 92 | +$maintClass = "RebuildTextIndex"; |
| 93 | +require_once( DO_MAINTENANCE ); |