BUG PM-393 muetsra un Notice al inicio cuando se realiza restore a la version PM 2.8 SOLVED
This commit is contained in:
@@ -61,7 +61,7 @@ class workspaceTools
|
|||||||
* @param bool $first true if this is the first workspace to be upgrade
|
* @param bool $first true if this is the first workspace to be upgrade
|
||||||
*/
|
*/
|
||||||
public function upgrade($first = false, $buildCacheView = false, $workSpace = SYS_SYS, $onedb = false, $lang = 'en')
|
public function upgrade($first = false, $buildCacheView = false, $workSpace = SYS_SYS, $onedb = false, $lang = 'en')
|
||||||
{
|
{
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
CLI::logging("> Verify enterprise old...\n");
|
CLI::logging("> Verify enterprise old...\n");
|
||||||
$this->verifyEnterprise($workSpace);
|
$this->verifyEnterprise($workSpace);
|
||||||
@@ -111,63 +111,63 @@ class workspaceTools
|
|||||||
$final = $stop - $start;
|
$final = $stop - $start;
|
||||||
CLI::logging("<*> Backup log files Process took $final seconds.\n");
|
CLI::logging("<*> Backup log files Process took $final seconds.\n");
|
||||||
|
|
||||||
CLI::logging("> Updating Files Manager...\n\n");
|
CLI::logging("> Updating Files Manager...\n\n");
|
||||||
$this->upgradeFilesManager($workSpace);
|
$this->upgradeFilesManager($workSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function upgradeFilesManager
|
* Function upgradeFilesManager
|
||||||
* access public
|
* access public
|
||||||
*/
|
*/
|
||||||
public function upgradeFilesManager($workSpace) {
|
public function upgradeFilesManager($workSpace) {
|
||||||
$this->initPropel(true);
|
$this->initPropel(true);
|
||||||
$con = Propel::getConnection("root");
|
$con = Propel::getConnection("root");
|
||||||
$stmt = $con->createStatement();
|
$stmt = $con->createStatement();
|
||||||
$sDirectory = glob(PATH_DATA . "sites/" . $workSpace . "/" . "mailTemplates/*");
|
$sDirectory = glob(PATH_DATA . "sites/" . $workSpace . "/" . "mailTemplates/*");
|
||||||
$sDirectoryPublic = glob(PATH_DATA . "sites/" . $workSpace . "/" . "public/*");
|
$sDirectoryPublic = glob(PATH_DATA . "sites/" . $workSpace . "/" . "public/*");
|
||||||
$files = array();
|
$files = array();
|
||||||
foreach($sDirectory as $mailTemplate) {
|
foreach($sDirectory as $mailTemplate) {
|
||||||
if (is_dir($mailTemplate)) {
|
if (is_dir($mailTemplate)) {
|
||||||
$inner_files = listFiles($mailTemplate);
|
$inner_files = listFiles($mailTemplate);
|
||||||
if (is_array($inner_files)) $files = array_merge($files, $inner_files);
|
if (is_array($inner_files)) $files = array_merge($files, $inner_files);
|
||||||
}
|
}
|
||||||
if (is_file($mailTemplate)) {
|
if (is_file($mailTemplate)) {
|
||||||
array_push($files, $mailTemplate);
|
array_push($files, $mailTemplate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach($sDirectoryPublic as $publicFile) {
|
foreach($sDirectoryPublic as $publicFile) {
|
||||||
if (is_dir($publicFile)) {
|
if (is_dir($publicFile)) {
|
||||||
$inner_files = listFiles($publicFile);
|
$inner_files = listFiles($publicFile);
|
||||||
if (is_array($inner_files)) $files = array_merge($files, $inner_files);
|
if (is_array($inner_files)) $files = array_merge($files, $inner_files);
|
||||||
}
|
}
|
||||||
if (is_file($publicFile)) {
|
if (is_file($publicFile)) {
|
||||||
array_push($files, $publicFile);
|
array_push($files, $publicFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sDir = PATH_DATA . "sites/" . $workSpace . "/" . "mailTemplates/";
|
$sDir = PATH_DATA . "sites/" . $workSpace . "/" . "mailTemplates/";
|
||||||
$sDirPublic = PATH_DATA . "sites/" . $workSpace . "/" . "public/";
|
$sDirPublic = PATH_DATA . "sites/" . $workSpace . "/" . "public/";
|
||||||
foreach ($files as $aFile) {
|
foreach ($files as $aFile) {
|
||||||
if (strpos($aFile, $sDir) !== false){
|
if (strpos($aFile, $sDir) !== false){
|
||||||
$processUid = current(explode("/", str_replace($sDir,'',$aFile)));
|
$processUid = current(explode("/", str_replace($sDir,'',$aFile)));
|
||||||
} else {
|
} else {
|
||||||
$processUid = current(explode("/", str_replace($sDirPublic,'',$aFile)));
|
$processUid = current(explode("/", str_replace($sDirPublic,'',$aFile)));
|
||||||
}
|
}
|
||||||
$sql = "SELECT PROCESS_FILES.PRF_PATH FROM PROCESS_FILES WHERE PROCESS_FILES.PRF_PATH='" . $aFile ."'";
|
$sql = "SELECT PROCESS_FILES.PRF_PATH FROM PROCESS_FILES WHERE PROCESS_FILES.PRF_PATH='" . $aFile ."'";
|
||||||
$appRows = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
|
$appRows = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
|
||||||
$fileUid = '';
|
$fileUid = '';
|
||||||
foreach ($appRows as $row) {
|
foreach ($appRows as $row) {
|
||||||
$fileUid = $row["PRF_PATH"];
|
$fileUid = $row["PRF_PATH"];
|
||||||
}
|
}
|
||||||
if ($fileUid !== $aFile) {
|
if ($fileUid !== $aFile) {
|
||||||
$sPkProcessFiles = G::generateUniqueID();
|
$sPkProcessFiles = G::generateUniqueID();
|
||||||
$sDate = date('Y-m-d H:i:s');
|
$sDate = date('Y-m-d H:i:s');
|
||||||
$sql = "INSERT INTO PROCESS_FILES (PRF_UID, PRO_UID, USR_UID, PRF_UPDATE_USR_UID,
|
$sql = "INSERT INTO PROCESS_FILES (PRF_UID, PRO_UID, USR_UID, PRF_UPDATE_USR_UID,
|
||||||
PRF_PATH, PRF_TYPE, PRF_EDITABLE, PRF_CREATE_DATE, PRF_UPDATE_DATE)
|
PRF_PATH, PRF_TYPE, PRF_EDITABLE, PRF_CREATE_DATE, PRF_UPDATE_DATE)
|
||||||
VALUES ('".$sPkProcessFiles."', '".$processUid."', '00000000000000000000000000000001', '',
|
VALUES ('".$sPkProcessFiles."', '".$processUid."', '00000000000000000000000000000001', '',
|
||||||
'".$aFile."', 'file', 'true', '".$sDate."', NULL)";
|
'".$aFile."', 'file', 'true', '".$sDate."', NULL)";
|
||||||
$stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
|
$stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -223,7 +223,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:
|
||||||
@@ -231,7 +231,7 @@ class workspaceTools
|
|||||||
*/
|
*/
|
||||||
$key = isset($matches['key']) ? $matches['key'] : $matches[2];
|
$key = isset($matches['key']) ? $matches['key'] : $matches[2];
|
||||||
$value = isset($matches['value']) ? $matches['value'] : $matches[3];
|
$value = isset($matches['value']) ? $matches['value'] : $matches[3];
|
||||||
|
|
||||||
if($this->onedb){
|
if($this->onedb){
|
||||||
$dbPrefix = array('DB_NAME' => 'wf_', 'DB_USER' => 'wf_', 'DB_RBAC_NAME' => 'wf_', 'DB_RBAC_USER' => 'wf_', 'DB_REPORT_NAME' => 'wf_', 'DB_REPORT_USER' => 'wf_');
|
$dbPrefix = array('DB_NAME' => 'wf_', 'DB_USER' => 'wf_', 'DB_RBAC_NAME' => 'wf_', 'DB_RBAC_USER' => 'wf_', 'DB_REPORT_NAME' => 'wf_', 'DB_REPORT_USER' => 'wf_');
|
||||||
if (array_search($key, array('DB_PASS', 'DB_RBAC_PASS', 'DB_REPORT_PASS'))) {
|
if (array_search($key, array('DB_PASS', 'DB_RBAC_PASS', 'DB_REPORT_PASS'))) {
|
||||||
@@ -286,7 +286,7 @@ class workspaceTools
|
|||||||
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 {
|
} else {
|
||||||
@@ -296,7 +296,7 @@ class workspaceTools
|
|||||||
$this->onedb = true;
|
$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>');"
|
||||||
@@ -540,7 +540,7 @@ class workspaceTools
|
|||||||
* @param string $lang not currently used
|
* @param string $lang not currently used
|
||||||
*/
|
*/
|
||||||
public function upgradeCacheView($fill = true, $checkOnly = false, $lang = "en")
|
public function upgradeCacheView($fill = true, $checkOnly = false, $lang = "en")
|
||||||
{
|
{
|
||||||
$this->initPropel(true);
|
$this->initPropel(true);
|
||||||
|
|
||||||
//require_once ('classes/model/AppCacheView.php');
|
//require_once ('classes/model/AppCacheView.php');
|
||||||
@@ -554,19 +554,19 @@ class workspaceTools
|
|||||||
//setup the appcacheview object, and the path for the sql files
|
//setup the appcacheview object, and the path for the sql files
|
||||||
$appCache = new AppCacheView();
|
$appCache = new AppCacheView();
|
||||||
$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 tables \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();
|
||||||
@@ -574,7 +574,7 @@ class workspaceTools
|
|||||||
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);
|
||||||
|
|
||||||
CLI::logging("-> Verifying roles permissions in RBAC \n");
|
CLI::logging("-> Verifying roles permissions in RBAC \n");
|
||||||
//Update table RBAC permissions
|
//Update table RBAC permissions
|
||||||
Bootstrap::LoadSystem( 'rbac' );
|
Bootstrap::LoadSystem( 'rbac' );
|
||||||
@@ -758,7 +758,7 @@ class workspaceTools
|
|||||||
* @return array bool upgradeSchema for more information
|
* @return array bool upgradeSchema for more information
|
||||||
*/
|
*/
|
||||||
public function upgradeDatabase ($onedb = false, $checkOnly = false)
|
public function upgradeDatabase ($onedb = false, $checkOnly = false)
|
||||||
{
|
{
|
||||||
G::LoadClass("patch");
|
G::LoadClass("patch");
|
||||||
$this->initPropel( true );
|
$this->initPropel( true );
|
||||||
p11835::$dbAdapter = $this->dbAdapter;
|
p11835::$dbAdapter = $this->dbAdapter;
|
||||||
@@ -800,7 +800,7 @@ class workspaceTools
|
|||||||
public function upgradeSchema($schema, $checkOnly = false, $rbac = false, $onedb = false)
|
public function upgradeSchema($schema, $checkOnly = false, $rbac = false, $onedb = false)
|
||||||
{
|
{
|
||||||
$dbInfo = $this->getDBInfo();
|
$dbInfo = $this->getDBInfo();
|
||||||
|
|
||||||
if ($dbInfo['DB_NAME'] == $dbInfo['DB_RBAC_NAME']) {
|
if ($dbInfo['DB_NAME'] == $dbInfo['DB_RBAC_NAME']) {
|
||||||
$onedb = true;
|
$onedb = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -1032,7 +1032,7 @@ class workspaceTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
$wfDsn = $fields['DB_ADAPTER'] . '://' . $fields['DB_USER'] . ':' . $fields['DB_PASS'] . '@' . $fields['DB_HOST'] . '/' . $fields['DB_NAME'];
|
$wfDsn = $fields['DB_ADAPTER'] . '://' . $fields['DB_USER'] . ':' . $fields['DB_PASS'] . '@' . $fields['DB_HOST'] . '/' . $fields['DB_NAME'];
|
||||||
|
|
||||||
$info = array('Workspace Name' => $fields['WORKSPACE_NAME'],
|
$info = array('Workspace Name' => $fields['WORKSPACE_NAME'],
|
||||||
//'Available Databases' => $fields['AVAILABLE_DB'],
|
//'Available Databases' => $fields['AVAILABLE_DB'],
|
||||||
'Workflow Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_USER'], $fields['DB_PASS'], $fields['DB_HOST'], $fields['DB_NAME']), 'RBAC Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_RBAC_USER'], $fields['DB_RBAC_PASS'], $fields['DB_RBAC_HOST'], $fields['DB_RBAC_NAME']), 'Report Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_REPORT_USER'], $fields['DB_REPORT_PASS'], $fields['DB_REPORT_HOST'], $fields['DB_REPORT_NAME']), 'MySql Version' => $fields['DATABASE']
|
'Workflow Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_USER'], $fields['DB_PASS'], $fields['DB_HOST'], $fields['DB_NAME']), 'RBAC Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_RBAC_USER'], $fields['DB_RBAC_PASS'], $fields['DB_RBAC_HOST'], $fields['DB_RBAC_NAME']), 'Report Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_REPORT_USER'], $fields['DB_REPORT_PASS'], $fields['DB_REPORT_HOST'], $fields['DB_REPORT_NAME']), 'MySql Version' => $fields['DATABASE']
|
||||||
@@ -1262,6 +1262,7 @@ class workspaceTools
|
|||||||
|
|
||||||
$lines = explode("\n", $script);
|
$lines = explode("\n", $script);
|
||||||
$previous = null;
|
$previous = null;
|
||||||
|
$insert = false;
|
||||||
foreach ($lines as $j => $line) {
|
foreach ($lines as $j => $line) {
|
||||||
// Remove comments from the script
|
// Remove comments from the script
|
||||||
$line = trim($line);
|
$line = trim($line);
|
||||||
@@ -1286,6 +1287,7 @@ class workspaceTools
|
|||||||
$line = substr($line, 0, strrpos($line, ";"));
|
$line = substr($line, 0, strrpos($line, ";"));
|
||||||
|
|
||||||
if (strrpos($line, "INSERT INTO") !== false) {
|
if (strrpos($line, "INSERT INTO") !== false) {
|
||||||
|
$insert = true;
|
||||||
if ($insert) {
|
if ($insert) {
|
||||||
$result = mysql_query("START TRANSACTION");
|
$result = mysql_query("START TRANSACTION");
|
||||||
$insert = false;
|
$insert = false;
|
||||||
@@ -1355,7 +1357,7 @@ class workspaceTools
|
|||||||
$chmod = @chmod($filename, $perms);
|
$chmod = @chmod($filename, $perms);
|
||||||
if ($chgrp === false || $chmod === false || $chown === false) {
|
if ($chgrp === false || $chmod === false || $chown === false) {
|
||||||
if (strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN') {
|
if (strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN') {
|
||||||
exec( 'icacls ' . $dirNameWin . '/grant Administrador:(D,WDAC) /T', $res );
|
exec( 'icacls ' . $filename . '/grant Administrador:(D,WDAC) /T', $res );
|
||||||
} else {
|
} else {
|
||||||
CLI::logging(CLI::error("Failed to set permissions for $filename") . "\n");
|
CLI::logging(CLI::error("Failed to set permissions for $filename") . "\n");
|
||||||
}
|
}
|
||||||
@@ -1447,9 +1449,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 {
|
||||||
@@ -1489,7 +1491,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) {
|
||||||
@@ -1596,7 +1598,7 @@ class workspaceTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function checkMafeRequirements ($workspace,$lang) {
|
public function checkMafeRequirements ($workspace,$lang) {
|
||||||
$this->initPropel(true);
|
$this->initPropel(true);
|
||||||
$pmRestClient = OauthClientsPeer::retrieveByPK('x-pm-local-client');
|
$pmRestClient = OauthClientsPeer::retrieveByPK('x-pm-local-client');
|
||||||
if (empty($pmRestClient)) {
|
if (empty($pmRestClient)) {
|
||||||
if (is_file(PATH_DATA . 'sites/' . $workspace . '/' . '.server_info')) {
|
if (is_file(PATH_DATA . 'sites/' . $workspace . '/' . '.server_info')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user