BUG15479 Error during workspace restore
Error during the workspaces restore
This commit is contained in:
@@ -158,7 +158,7 @@ class workspaceTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function resetDBInfoCallback($matches)
|
private function resetDBInfoCallback($matches)
|
||||||
{
|
{
|
||||||
/* This function changes the values of defines while keeping their formatting
|
/* This function changes the values of defines while keeping their formatting
|
||||||
* intact.
|
* intact.
|
||||||
* $matches will contain several groups:
|
* $matches will contain several groups:
|
||||||
@@ -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,20 +489,22 @@ 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();
|
||||||
|
|
||||||
CLI::logging("-> Update DEL_LAST_INDEX field in APP_DELEGATION table\n");
|
CLI::logging("-> Update DEL_LAST_INDEX field in APP_DELEGATION table \n");
|
||||||
//Update APP_DELEGATION.DEL_LAST_INDEX data
|
//Update APP_DELEGATION.DEL_LAST_INDEX data
|
||||||
$res = $appCache->updateAppDelegationDelLastIndex($lang, $checkOnly);
|
$res = $appCache->updateAppDelegationDelLastIndex($lang, $checkOnly);
|
||||||
|
|
||||||
@@ -820,7 +830,7 @@ class workspaceTools
|
|||||||
$sql = '';
|
$sql = '';
|
||||||
switch ($data['action']) {
|
switch ($data['action']) {
|
||||||
case 1:
|
case 1:
|
||||||
$sql = $dataBase->generateInsertSQL($data['table'], $data['data']);
|
$sql = $dataoneBase->generateInsertSQL($data['table'], $data['data']);
|
||||||
$message = "-> Row added in {$data['table']}\n";
|
$message = "-> Row added in {$data['table']}\n";
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
@@ -1350,7 +1360,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 {
|
||||||
@@ -1390,7 +1402,7 @@ class workspaceTools
|
|||||||
if (!$link) {
|
if (!$link) {
|
||||||
throw new Exception('Could not connect to system database: ' . mysql_error());
|
throw new Exception('Could not connect to system database: ' . mysql_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
$newDBNames = $workspace->resetDBInfo($dbHost, $createWorkspace);
|
$newDBNames = $workspace->resetDBInfo($dbHost, $createWorkspace);
|
||||||
|
|
||||||
foreach ($metadata->databases as $db) {
|
foreach ($metadata->databases as $db) {
|
||||||
@@ -1420,7 +1432,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user