Merged in norah/processmaker/BUG15479 (pull request #790)

BUG-15479 Error durante la restauracion de workspaces
This commit is contained in:
Julio Cesar Laura Avendaño
2014-09-17 14:38:28 -04:00

View File

@@ -174,7 +174,6 @@ class workspaceTools
} }
} }
if (array_search($key, array('DB_HOST', 'DB_RBAC_HOST', 'DB_REPORT_HOST')) !== false) { if (array_search($key, array('DB_HOST', 'DB_RBAC_HOST', 'DB_REPORT_HOST')) !== false) {
/* Change the database hostname for these keys */ /* Change the database hostname for these keys */
$value = $this->newHost; $value = $this->newHost;
@@ -214,14 +213,23 @@ class workspaceTools
$this->newHost = $newHost; $this->newHost = $newHost;
$this->resetDBNames = $resetDBNames; $this->resetDBNames = $resetDBNames;
$this->resetDBDiff = array(); $this->resetDBDiff = array();
$this->onedb = false;
if (!$this->workspaceExists()) { if (!$this->workspaceExists()) {
throw new Exception("Could not find db.php in the workspace"); throw new Exception("Could not find db.php in the workspace");
} }
$sDbFile = file_get_contents($this->dbPath); $sDbFile = file_get_contents($this->dbPath);
if ($sDbFile === false) { if ($sDbFile === false) {
throw new Exception("Could not read database information from db.php"); throw new Exception("Could not read database information from db.php");
} else {
if (strpos($sDbFile, 'rb_')) {
$this->onedb = false;
} else {
$this->onedb = true;
} }
}
/* Match all defines in the config file. Check updateDBCallback to know what /* Match all defines in the config file. Check updateDBCallback to know what
* keys are changed and what groups are matched. * keys are changed and what groups are matched.
* This regular expression will match any "define ('<key>', '<value>');" * This regular expression will match any "define ('<key>', '<value>');"
@@ -481,16 +489,18 @@ class workspaceTools
$appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP); $appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP);
$userGrants = $appCache->checkGrantsForUser(false); $userGrants = $appCache->checkGrantsForUser(false);
$currentUser = $userGrants['user']; $currentUser = $userGrants['user'];
$currentUserIsSuper = $userGrants['super']; $currentUserIsSuper = $userGrants['super'];
//if user does not have the SUPER privilege we need to use the root user and grant the SUPER priv. to normal user. //if user does not have the SUPER privilege we need to use the root user and grant the SUPER priv. to normal user.
if (!$currentUserIsSuper) { if (!$currentUserIsSuper) {
$appCache->checkGrantsForUser(true); $appCache->checkGrantsForUser(true);
$appCache->setSuperForUser($currentUser); $appCache->setSuperForUser($currentUser);
$currentUserIsSuper = true; $currentUserIsSuper = true;
} }
CLI::logging("-> Creating table\n"); CLI::logging("-> Creating tables \n");
//now check if table APPCACHEVIEW exists, and it have correct number of fields, etc. //now check if table APPCACHEVIEW exists, and it have correct number of fields, etc.
$res = $appCache->checkAppCacheView(); $res = $appCache->checkAppCacheView();
@@ -1370,7 +1380,9 @@ class workspaceTools
CLI::logging("> Restoring " . CLI::info($backupWorkspace) . " to " . CLI::info($workspaceName) . "\n"); CLI::logging("> Restoring " . CLI::info($backupWorkspace) . " to " . CLI::info($workspaceName) . "\n");
} }
$workspace = new workspaceTools($workspaceName); $workspace = new workspaceTools($workspaceName);
if ($workspace->workspaceExists()) { if ($workspace->workspaceExists()) {
if ($overwrite) { if ($overwrite) {
CLI::logging(CLI::warning("> Workspace $workspaceName already exist, overwriting!") . "\n"); CLI::logging(CLI::warning("> Workspace $workspaceName already exist, overwriting!") . "\n");
} else { } else {
@@ -1440,7 +1452,6 @@ class workspaceTools
$final = $stop - $start; $final = $stop - $start;
CLI::logging("<*> Updating cache view Process took $final seconds.\n"); CLI::logging("<*> Updating cache view Process took $final seconds.\n");
mysql_close($link); mysql_close($link);
} }