X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=maintenance%2FconvertLinks.inc;h=92c59550c40d2d606a56ab2e2812f47cd4657bea;hb=c771fc9c96aacb44b86ade5ecca68334c5d8213f;hp=0a784957d0555dd39fe3fb4b76206511c35267e4;hpb=5bd8b35624de0b040cc42e7d52f61f7089a6f2bd;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/convertLinks.inc b/maintenance/convertLinks.inc index 0a784957d0..92c59550c4 100644 --- a/maintenance/convertLinks.inc +++ b/maintenance/convertLinks.inc @@ -1,24 +1,23 @@ tableNames( 'cur', 'links', 'links_temp', 'links_backup' ) ); + list ($cur, $links, $links_temp, $links_backup) = $dbw->tableNamesN( 'cur', 'links', 'links_temp', 'links_backup' ); $res = $dbw->query( "SELECT l_from FROM $links LIMIT 1" ); if ( $dbw->fieldType( $res, 0 ) == "int" ) { print "Schema already converted\n"; return; } - + $res = $dbw->query( "SELECT COUNT(*) AS count FROM $links" ); $row = $dbw->fetchObject($res); $numRows = $row->count; @@ -67,8 +66,8 @@ function convertLinks() { print "Loading IDs from $cur table...\n"; performanceLog ( "Reading $numRows rows from cur table...\n" ); performanceLog ( "rows read vs seconds elapsed:\n" ); - - $dbw->setBufferResults( false ); + + $dbw->bufferResults( false ); $res = $dbw->query( "SELECT cur_namespace,cur_title,cur_id FROM $cur" ); $ids = array(); @@ -82,12 +81,12 @@ function convertLinks() { if ($reportCurReadProgress) { if (($curRowsRead % $curReadReportInterval) == 0) { performanceLog( $curRowsRead . " " . (getMicroTime() - $baseTime) . "\n" ); - print "\t$curRowsRead rows of $cur table read.\n"; + print "\t$curRowsRead rows of $cur table read.\n"; } } } $dbw->freeResult( $res ); - $dbw->setBufferResults( true ); + $dbw->bufferResults( true ); print "Finished loading IDs.\n\n"; performanceLog( "Took " . (getMicroTime() - $baseTime) . " seconds to load IDs.\n\n" ); #-------------------------------------------------------------------- @@ -100,19 +99,20 @@ function convertLinks() { print "Processing $numRows rows from $links table...\n"; performanceLog( "Processing $numRows rows from $links table...\n" ); performanceLog( "rows inserted vs seconds elapsed:\n" ); - + for ($rowOffset = $initialRowOffset; $rowOffset < $numRows; $rowOffset += $linksConvInsertInterval) { - $sqlRead = "SELECT * FROM $links ".wfLimitResult($linksConvInsertInterval,$rowOffset); + $sqlRead = "SELECT * FROM $links "; + $sqlRead = $dbw->limitResult($sqlRead, $linksConvInsertInterval,$rowOffset); $res = $dbw->query($sqlRead); if ( $noKeys ) { $sqlWrite = array("INSERT INTO $links_temp (l_from,l_to) VALUES "); } else { $sqlWrite = array("INSERT IGNORE INTO $links_temp (l_from,l_to) VALUES "); } - + $tuplesAdded = 0; # no tuples added to INSERT yet while ( $row = $dbw->fetchObject($res) ) { - $fromTitle = $row->l_from; + $fromTitle = $row->l_from; if ( array_key_exists( $fromTitle, $ids ) ) { # valid title $from = $ids[$fromTitle]; $to = $row->l_to; @@ -120,7 +120,7 @@ function convertLinks() { $sqlWrite[] = ","; } $sqlWrite[] = "($from,$to)"; - $tuplesAdded++; + $tuplesAdded++; } else { # invalid title $numBadLinks++; } @@ -155,12 +155,12 @@ function convertLinks() { print "Dropping backup links table if it exists..."; $dbConn->query( "DROP TABLE IF EXISTS $links_backup", DB_MASTER); print " done.\n"; - + # Swap in the new table, and move old links table to links_backup print "Swapping tables '$links' to '$links_backup'; '$links_temp' to '$links'..."; $dbConn->query( "RENAME TABLE links TO $links_backup, $links_temp TO $links", DB_MASTER ); print " done.\n\n"; - + $dbConn->close(); print "Conversion complete. The old table remains at $links_backup;\n"; print "delete at your leisure.\n"; @@ -176,17 +176,17 @@ function createTempTable() { global $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname; global $noKeys; $dbConn = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); - + if (!($dbConn->isOpen())) { print "Opening connection to database failed.\n"; return; } $links_temp = $dbConn->tableName( 'links_temp' ); - + print "Dropping temporary links table if it exists..."; $dbConn->query( "DROP TABLE IF EXISTS $links_temp"); print " done.\n"; - + print "Creating temporary links table..."; if ( $noKeys ) { $dbConn->query( "CREATE TABLE $links_temp ( " .