X-Git-Url: https://git.cyclocoop.org/admin/?a=blobdiff_plain;f=maintenance%2FconvertLinks.php;h=221ebe37a3d54707dd2a27ab56d849e81291965a;hb=c2d702b73e1ee2136533c03bb29e178e48b7b763;hp=6840a01bb8dcdd15542598ad76c2ae8c66354e48;hpb=752c7081495438e7199d966c3a8757a11489e16e;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/convertLinks.php b/maintenance/convertLinks.php index 6840a01bb8..221ebe37a3 100644 --- a/maintenance/convertLinks.php +++ b/maintenance/convertLinks.php @@ -71,6 +71,7 @@ class ConvertLinks extends Maintenance { $type = $dbw->getType(); if ( $type != 'mysql' ) { $this->output( "Link table conversion not necessary for $type\n" ); + return; } @@ -111,12 +112,14 @@ class ConvertLinks extends Maintenance { if ( $dbw->tableExists( 'pagelinks' ) ) { $this->output( "...have pagelinks; skipping old links table updates\n" ); + return; } $res = $dbw->query( "SELECT l_from FROM $links LIMIT 1" ); if ( $dbw->fieldType( $res, 0 ) == "int" ) { $this->output( "Schema already converted\n" ); + return; } @@ -131,17 +134,17 @@ class ConvertLinks extends Maintenance { } else { $fh = false; if ( $this->logPerformance ) { - $fh = fopen ( $perfLogFilename, "w" ); + $fh = fopen( $perfLogFilename, "w" ); if ( !$fh ) { $this->error( "Couldn't open $perfLogFilename" ); $this->logPerformance = false; } } - $baseTime = $startTime = $this->getMicroTime(); + $baseTime = $startTime = microtime( true ); # Create a title -> cur_id map $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" ); + $this->performanceLog( $fh, "Reading $numRows rows from cur table...\n" ); + $this->performanceLog( $fh, "rows read vs seconds elapsed:\n" ); $dbw->bufferResults( false ); $res = $dbw->query( "SELECT cur_namespace,cur_title,cur_id FROM $cur" ); @@ -158,7 +161,7 @@ class ConvertLinks extends Maintenance { if ( ( $curRowsRead % $curReadReportInterval ) == 0 ) { $this->performanceLog( $fh, - $curRowsRead . " " . ( $this->getMicroTime() - $baseTime ) . "\n" + $curRowsRead . " " . ( microtime( true ) - $baseTime ) . "\n" ); $this->output( "\t$curRowsRead rows of $cur table read.\n" ); } @@ -169,7 +172,7 @@ class ConvertLinks extends Maintenance { $this->output( "Finished loading IDs.\n\n" ); $this->performanceLog( $fh, - "Took " . ( $this->getMicroTime() - $baseTime ) . " seconds to load IDs.\n\n" + "Took " . ( microtime( true ) - $baseTime ) . " seconds to load IDs.\n\n" ); # -------------------------------------------------------------------- @@ -178,7 +181,7 @@ class ConvertLinks extends Maintenance { # convert, and write to the new table. $this->createTempTable(); $this->performanceLog( $fh, "Resetting timer.\n\n" ); - $baseTime = $this->getMicroTime(); + $baseTime = microtime( true ); $this->output( "Processing $numRows rows from $links table...\n" ); $this->performanceLog( $fh, "Processing $numRows rows from $links table...\n" ); $this->performanceLog( $fh, "rows inserted vs seconds elapsed:\n" ); @@ -223,7 +226,7 @@ class ConvertLinks extends Maintenance { $this->output( " done. Total $totalTuplesInserted tuples inserted.\n" ); $this->performanceLog( $fh, - $totalTuplesInserted . " " . ( $this->getMicroTime() - $baseTime ) . "\n" + $totalTuplesInserted . " " . ( microtime( true ) - $baseTime ) . "\n" ); } } @@ -236,10 +239,10 @@ class ConvertLinks extends Maintenance { ); $this->performanceLog( $fh, - "Total execution time: " . ( $this->getMicroTime() - $startTime ) . " seconds.\n" + "Total execution time: " . ( microtime( true ) - $startTime ) . " seconds.\n" ); if ( $this->logPerformance ) { - fclose ( $fh ); + fclose( $fh ); } } # -------------------------------------------------------------------- @@ -268,6 +271,7 @@ class ConvertLinks extends Maintenance { if ( !( $dbConn->isOpen() ) ) { $this->output( "Opening connection to database failed.\n" ); + return; } $links_temp = $dbConn->tableName( 'links_temp' ); @@ -279,14 +283,14 @@ class ConvertLinks extends Maintenance { $this->output( "Creating temporary links table..." ); if ( $this->hasOption( 'noKeys' ) ) { $dbConn->query( "CREATE TABLE $links_temp ( " . - "l_from int(8) unsigned NOT NULL default '0', " . - "l_to int(8) unsigned NOT NULL default '0')" ); + "l_from int(8) unsigned NOT NULL default '0', " . + "l_to int(8) unsigned NOT NULL default '0')" ); } else { $dbConn->query( "CREATE TABLE $links_temp ( " . - "l_from int(8) unsigned NOT NULL default '0', " . - "l_to int(8) unsigned NOT NULL default '0', " . - "UNIQUE KEY l_from(l_from,l_to), " . - "KEY (l_to))" ); + "l_from int(8) unsigned NOT NULL default '0', " . + "l_to int(8) unsigned NOT NULL default '0', " . + "UNIQUE KEY l_from(l_from,l_to), " . + "KEY (l_to))" ); } $this->output( " done.\n\n" ); } @@ -296,11 +300,6 @@ class ConvertLinks extends Maintenance { fwrite( $fh, $text ); } } - - private function getMicroTime() { # return time in seconds, with microsecond accuracy - list( $usec, $sec ) = explode( " ", microtime() ); - return ( (float)$usec + (float)$sec ); - } } $maintClass = "ConvertLinks";