Index: trunk/phase3/maintenance/updaters.inc |
— | — | @@ -9,7 +9,6 @@ |
10 | 10 | exit( 1 ); |
11 | 11 | } |
12 | 12 | |
13 | | -require_once 'convertLinks.inc'; |
14 | 13 | require_once 'userDupes.inc'; |
15 | 14 | # Extension updates |
16 | 15 | require_once( "$IP/includes/Hooks.php" ); |
— | — | @@ -514,12 +513,12 @@ |
515 | 514 | } |
516 | 515 | |
517 | 516 | function do_old_links_update() { |
518 | | - global $wgDatabase; |
519 | | - if ( $wgDatabase->tableExists( 'pagelinks' ) ) { |
520 | | - wfOut( "...have pagelinks; skipping old links table updates.\n" ); |
521 | | - } else { |
522 | | - convertLinks(); flush(); |
| 517 | + if( !defined( 'MW_NO_SETUP' ) ) { |
| 518 | + define( 'MW_NO_SETUP', true ); |
523 | 519 | } |
| 520 | + require( "convertLinks.php" ); |
| 521 | + $cl = new ConvertLinks(); |
| 522 | + $cl->execute(); |
524 | 523 | } |
525 | 524 | |
526 | 525 | function fix_ancient_imagelinks() { |
Index: trunk/phase3/maintenance/convertLinks.php |
— | — | @@ -31,17 +31,22 @@ |
32 | 32 | The wiki should be put into read-only mode while this script executes"; |
33 | 33 | } |
34 | 34 | |
| 35 | + public function getDbType() { |
| 36 | + return self::DB_ADMIN; |
| 37 | + } |
| 38 | + |
35 | 39 | public function execute() { |
36 | 40 | global $wgDBtype; |
37 | | - if ( $wgDBtype == 'postgres' ) { |
38 | | - $this->output( "Links table already ok on Postgres.\n" ); |
| 41 | + |
| 42 | + $dbw = wfGetDB( DB_MASTER ); |
| 43 | + |
| 44 | + $type = $dbw->getType(); |
| 45 | + if ( $type != 'mysql' ) { |
| 46 | + $this->output( "Link table conversion not necessary for $type\n" ); |
39 | 47 | return; |
40 | 48 | } |
41 | 49 | |
42 | | - $this->output( "Converting links table to ID-ID...\n" ); |
43 | | - |
44 | | - global $wgLang, $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname; |
45 | | - global $noKeys, $logPerformance, $fh; |
| 50 | + global $wgLang, $noKeys, $logPerformance, $fh; |
46 | 51 | |
47 | 52 | $tuplesAdded = $numBadLinks = $curRowsRead = 0; # counters etc |
48 | 53 | $totalTuplesInserted = 0; # total tuples INSERTed into links_temp |
— | — | @@ -68,8 +73,12 @@ |
69 | 74 | $perfLogFilename = "convLinksPerf.txt"; |
70 | 75 | # -------------------------------------------------------------------- |
71 | 76 | |
72 | | - $dbw = wfGetDB( DB_MASTER ); |
73 | 77 | list ( $cur, $links, $links_temp, $links_backup ) = $dbw->tableNamesN( 'cur', 'links', 'links_temp', 'links_backup' ); |
| 78 | + |
| 79 | + if( $dbw->tableExists( 'pagelinks' ) ) { |
| 80 | + $this->output( "...have pagelinks; skipping old links table updates\n" ); |
| 81 | + return; |
| 82 | + } |
74 | 83 | |
75 | 84 | $res = $dbw->query( "SELECT l_from FROM $links LIMIT 1" ); |
76 | 85 | if ( $dbw->fieldType( $res, 0 ) == "int" ) { |
— | — | @@ -172,22 +181,17 @@ |
173 | 182 | # -------------------------------------------------------------------- |
174 | 183 | |
175 | 184 | if ( $overwriteLinksTable ) { |
176 | | - $dbConn = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); |
177 | | - if ( !( $dbConn->isOpen() ) ) { |
178 | | - $this->output( "Opening connection to database failed.\n" ); |
179 | | - return; |
180 | | - } |
181 | 185 | # Check for existing links_backup, and delete it if it exists. |
182 | 186 | $this->output( "Dropping backup links table if it exists..." ); |
183 | | - $dbConn->query( "DROP TABLE IF EXISTS $links_backup", DB_MASTER ); |
| 187 | + $dbw->query( "DROP TABLE IF EXISTS $links_backup", DB_MASTER ); |
184 | 188 | $this->output( " done.\n" ); |
185 | 189 | |
186 | 190 | # Swap in the new table, and move old links table to links_backup |
187 | 191 | $this->output( "Swapping tables '$links' to '$links_backup'; '$links_temp' to '$links'..." ); |
188 | | - $dbConn->query( "RENAME TABLE links TO $links_backup, $links_temp TO $links", DB_MASTER ); |
| 192 | + $dbw->query( "RENAME TABLE links TO $links_backup, $links_temp TO $links", DB_MASTER ); |
189 | 193 | $this->output( " done.\n\n" ); |
190 | 194 | |
191 | | - $dbConn->close(); |
| 195 | + $dbw->close(); |
192 | 196 | $this->output( "Conversion complete. The old table remains at $links_backup;\n" ); |
193 | 197 | $this->output( "delete at your leisure.\n" ); |
194 | 198 | } else { |
— | — | @@ -197,9 +201,8 @@ |
198 | 202 | } |
199 | 203 | |
200 | 204 | private function createTempTable() { |
201 | | - global $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname; |
202 | 205 | global $noKeys; |
203 | | - $dbConn = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); |
| 206 | + $dbConn = wfGetDB( DB_MASTER ); |
204 | 207 | |
205 | 208 | if ( !( $dbConn->isOpen() ) ) { |
206 | 209 | $this->output( "Opening connection to database failed.\n" ); |