X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FconvertLinks.php;h=02152f7b6615f291268d30e6e2384ee48f0a11fe;hb=7414a955f889b0a0998c350b886c0a496897a21b;hp=af60eaa2ba81621c2f4a32b2b5776058e1c6d1c0;hpb=a4120368bb7797df25004613feed9406eac1c9d0;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/convertLinks.php b/maintenance/convertLinks.php index af60eaa2ba..02152f7b66 100644 --- a/maintenance/convertLinks.php +++ b/maintenance/convertLinks.php @@ -126,7 +126,6 @@ class ConvertLinks extends Maintenance { $res = $dbw->query( "SELECT COUNT(*) AS count FROM $links" ); $row = $dbw->fetchObject( $res ); $numRows = $row->count; - $dbw->freeResult( $res ); if ( $numRows == 0 ) { $this->output( "Updating schema (no rows to convert)...\n" ); @@ -145,31 +144,34 @@ class ConvertLinks extends Maintenance { $this->output( "Loading IDs from $cur table...\n" ); $this->performanceLog( $fh, "Reading $numRows rows from cur table...\n" ); $this->performanceLog( $fh, "rows read vs seconds elapsed:\n" ); + $contentLang = MediaWikiServices::getInstance()->getContentLanguage(); - $dbw->bufferResults( false ); - $res = $dbw->query( "SELECT cur_namespace,cur_title,cur_id FROM $cur" ); $ids = []; - - foreach ( $res as $row ) { - $title = $row->cur_title; - if ( $row->cur_namespace ) { - $title = MediaWikiServices::getInstance()->getContentLanguage()-> - getNsText( $row->cur_namespace ) . ":$title"; - } - $ids[$title] = $row->cur_id; - $curRowsRead++; - if ( $reportCurReadProgress ) { - if ( ( $curRowsRead % $curReadReportInterval ) == 0 ) { - $this->performanceLog( - $fh, - $curRowsRead . " " . ( microtime( true ) - $baseTime ) . "\n" - ); - $this->output( "\t$curRowsRead rows of $cur table read.\n" ); + $lastId = 0; + do { + $res = $dbw->query( + "SELECT cur_namespace,cur_title,cur_id FROM $cur " . + "WHERE cur_id > $lastId ORDER BY cur_id LIMIT 10000" + ); + foreach ( $res as $row ) { + $title = $row->cur_title; + if ( $row->cur_namespace ) { + $title = $contentLang->getNsText( $row->cur_namespace ) . ":$title"; + } + $ids[$title] = $row->cur_id; + $curRowsRead++; + if ( $reportCurReadProgress ) { + if ( ( $curRowsRead % $curReadReportInterval ) == 0 ) { + $this->performanceLog( + $fh, + $curRowsRead . " " . ( microtime( true ) - $baseTime ) . "\n" + ); + $this->output( "\t$curRowsRead rows of $cur table read.\n" ); + } } + $lastId = $row->cur_id; } - } - $dbw->freeResult( $res ); - $dbw->bufferResults( true ); + } while ( $res->numRows() > 0 ); $this->output( "Finished loading IDs.\n\n" ); $this->performanceLog( $fh, @@ -214,7 +216,6 @@ class ConvertLinks extends Maintenance { $numBadLinks++; } } - $dbw->freeResult( $res ); # $this->output( "rowOffset: $rowOffset\ttuplesAdded: " # . "$tuplesAdded\tnumBadLinks: $numBadLinks\n" ); if ( $tuplesAdded != 0 ) {