Permalink
Browse files

Stripped out an unnecessary line in pg_dump output which causes error.

Also deletes the last temp file while duplicating database to save space
  • Loading branch information...
patrickslee
patrickslee committed Mar 26, 2006
1 parent 40b4a06 commit 8cf1d8949eb1785aa51efd5f64b52b223981b751
Showing with 6 additions and 6 deletions.
  1. +6 −6 admin/utfdbmigrate.php
View
@@ -206,6 +206,7 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
if (isset($host[1])) $cmd .= " -p {$host[1]}";
}
$cmds[] = $cmd;
+ $cmds[] = 'grep -v "COMMENT ON SCHEMA"';
$cmds[] = 'iconv -f UTF-8 -t UTF-8 -c';
$cmd = "PGPASSWORD={$_SESSION['newpostgresdb']->dbpass} PGDATABASE={$_SESSION['newpostgresdb']->dbname} psql -q -U {$_SESSION['newpostgresdb']->dbuser} -v ON_ERROR_STOP=1$cluster";
if ($_SESSION['newpostgresdb']->dbhost) {
@@ -217,10 +218,11 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
foreach ($cmds as $key => $cmd) {
$files[] = tempnam($CFG->dataroot, 'utf8_');
exec($cmd . ($key?" < {$files[$key-1]}":'') . " 2>&1 > {$files[$key]}", $output, $return_var);
+ if ($key) {
+ unlink($files[$key-1]);
+ }
if ($return_var) { // we are dead!
- foreach ($files as $file) {
- unlink($file);
- }
+ unlink($files[$key]);
echo '<br />';
print_simple_box_start('center','50%');
print_string('dbmigrationdupfailed','admin',htmlspecialchars(implode("\n", $output)));
@@ -229,9 +231,7 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
exit;
}
}
- foreach ($files as $file) {
- unlink($file);
- }
+ unlink(array_pop($files));
}
$migrationconfig = new object;

0 comments on commit 8cf1d89

Please sign in to comment.