Index: trunk/tools/mwmultiversion/multiversion/populateWikiversionCDB.php |
— | — | @@ -37,25 +37,22 @@ |
38 | 38 | die( "Unable to read all.dblist." ); |
39 | 39 | } |
40 | 40 | |
41 | | - $wikiVersionList = ''; |
42 | | - foreach ( $dbList as $dbName ) { |
43 | | - $wikiVersionList .= "$dbName $version\n"; |
44 | | - } |
| 41 | + $tmpDBPath = "$common/wikiversions.cdb.tmp"; |
| 42 | + $finalDBPath = "$common/wikiversions.cdb"; |
45 | 43 | |
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." ); |
49 | 48 | } |
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 ); |
59 | 51 | } |
| 52 | + dba_close( $db ); |
| 53 | + |
| 54 | + # Move to final location only when finished... |
| 55 | + @unlink( $finalDBPath ); |
| 56 | + rename( $tmpDBPath, $finalDBPath ); |
60 | 57 | } |
61 | 58 | |
62 | 59 | populateWikiversionsCDB(); |