r92834 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92833‎ | r92834 | r92835 >
Date:00:36, 22 July 2011
Author:aaron
Status:ok (Comments)
Tags:
Comment:
Made populateWikiversionsCDB() function just use native php cdb_make functionality. Also, wmf doesn't have the cdbmake executable ;)
Modified paths:
  • /trunk/tools/mwmultiversion/multiversion/populateWikiversionCDB.php (modified) (history)

Diff [purge]

Index: trunk/tools/mwmultiversion/multiversion/populateWikiversionCDB.php
@@ -37,25 +37,22 @@
3838 die( "Unable to read all.dblist." );
3939 }
4040
41 - $wikiVersionList = '';
42 - foreach ( $dbList as $dbName ) {
43 - $wikiVersionList .= "$dbName $version\n";
44 - }
 41+ $tmpDBPath = "$common/wikiversions.cdb.tmp";
 42+ $finalDBPath = "$common/wikiversions.cdb";
4543
46 - $path = "$common/wikiversions.dat";
47 - if ( !file_put_contents( $path, $wikiVersionList ) ) {
48 - die( "Unable to write to wikiversions.dat.\n" );
 44+ # Build new database at temp location...
 45+ $db = dba_open( $tmpDBPath, "n", "cdb_make" );
 46+ if ( !$db ) {
 47+ die( "Unable to create wikiversions.cdb." );
4948 }
50 -
51 - $ret = 1; // failed by default?
52 - passthru( sprintf(
53 - "$common/multiversion/cdbmake-12.sh %s %s < $common/wikiversions.dat",
54 - "$common/wikiversions.cdb",
55 - "$common/wikiversions.dat.tmp"
56 - ) );
57 - if ( $ret != 0 ) {
58 - die( "Unable to write to wikiversions.cdb.\n" );
 49+ foreach ( $dbList as $dbName ) {
 50+ dba_insert( $dbName, $version, $db );
5951 }
 52+ dba_close( $db );
 53+
 54+ # Move to final location only when finished...
 55+ @unlink( $finalDBPath );
 56+ rename( $tmpDBPath, $finalDBPath );
6057 }
6158
6259 populateWikiversionsCDB();

Comments

#Comment by 😂 (talk | contribs)   19:00, 22 July 2011

The @ on unlink() is kind of ugly, but otherwise ok.

Status & tagging log