proposed.patch (3,256 bytes)
*** WADF-old.php 2009-11-19 14:49:23.000000000 +0000
--- WADF.php 2009-11-19 14:54:14.000000000 +0000
***************
*** 321,353 ****
}
}
$this->_debugOutput("Setting up database $name on host $host...", self::DEBUG_GENERAL);
if (!empty($schema)) {
$schema_path = "$dir/$schema";
if (file_exists($schema_path)) {
! // FIXME quote strings!
! $db_deploy_user = $this->resolveMacro("db${num}_deploy_user");
! $db_deploy_pass = $this->resolveMacro("db${num}_deploy_pass");
!
! $db = @mysql_connect($host, $db_deploy_user, $db_deploy_pass);
! if (!is_resource($db)) {
! throw new Exception("Could not connect to database (username=$db_deploy_user, password=$db_deploy_pass): ".mysql_error());
! }
!
! if (in_array('create', $deploy_options)) {
! mysql_query("CREATE DATABASE IF NOT EXISTS $name", $db);
! }
! if (in_array('grant', $deploy_options)) {
! mysql_query("GRANT ALL on $name.* to $user IDENTIFIED BY '$pass'", $db);
! }
! if (in_array('schema', $deploy_options)) {
! // Remove existing database tables
! $this->_removeDatabaseTables($name, $db);
!
// Deploy new schema
$this->_debugOutput("\tDeploying new schema for database $name as user $db_deploy_user...", self::DEBUG_GENERAL);
$cmd = "mysql $name -h $host -u $db_deploy_user ".(($db_deploy_pass != null) ? "-p$db_deploy_pass" : '')." < $dir/$schema 2>&1";
}
! mysql_close($db);
exec($cmd, $out, $ret);
if ($ret != 0) {
throw new Exception('Error when deploying schema: ' . implode("\n", $out));
--- 321,359 ----
}
}
$this->_debugOutput("Setting up database $name on host $host...", self::DEBUG_GENERAL);
+
+
+ // FIXME quote strings!
+ $db_deploy_user = $this->resolveMacro("db${num}_deploy_user");
+ $db_deploy_pass = $this->resolveMacro("db${num}_deploy_pass");
+
+ $db = @mysql_connect($host, $db_deploy_user, $db_deploy_pass);
+ if (!is_resource($db)) {
+ throw new Exception("Could not connect to database (username=$db_deploy_user, password=$db_deploy_pass): ".mysql_error());
+ }
+
+ if (in_array('create', $deploy_options)) {
+ mysql_query("CREATE DATABASE IF NOT EXISTS $name", $db);
+ }
+ if (in_array('grant', $deploy_options)) {
+ mysql_query("GRANT ALL on $name.* to $user IDENTIFIED BY '$pass'", $db);
+ }
+
+ // Remove existing database tables
+ $this->_removeDatabaseTables($name, $db);
+
+ mysql_close($db);
+
if (!empty($schema)) {
$schema_path = "$dir/$schema";
if (file_exists($schema_path)) {
!
! if (in_array('schema', $deploy_options)) {
// Deploy new schema
$this->_debugOutput("\tDeploying new schema for database $name as user $db_deploy_user...", self::DEBUG_GENERAL);
$cmd = "mysql $name -h $host -u $db_deploy_user ".(($db_deploy_pass != null) ? "-p$db_deploy_pass" : '')." < $dir/$schema 2>&1";
}
!
exec($cmd, $out, $ret);
if ($ret != 0) {
throw new Exception('Error when deploying schema: ' . implode("\n", $out));