BUG PM-393 muetsra un Notice al inicio cuando se realiza restore a la version PM 2.8 SOLVED

This commit is contained in:
Julio Cesar Laura
2014-10-03 10:31:50 -04:00
parent ffc598a918
commit 2015aea438

View File

@@ -61,7 +61,7 @@ class workspaceTools
* @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')
{
{
$start = microtime(true);
CLI::logging("> Verify enterprise old...\n");
$this->verifyEnterprise($workSpace);
@@ -111,63 +111,63 @@ class workspaceTools
$final = $stop - $start;
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);
}
/**
* Function upgradeFilesManager
* access public
*/
public function upgradeFilesManager($workSpace) {
/**
* Function upgradeFilesManager
* access public
*/
public function upgradeFilesManager($workSpace) {
$this->initPropel(true);
$con = Propel::getConnection("root");
$stmt = $con->createStatement();
$sDirectory = glob(PATH_DATA . "sites/" . $workSpace . "/" . "mailTemplates/*");
$sDirectoryPublic = glob(PATH_DATA . "sites/" . $workSpace . "/" . "public/*");
$files = array();
foreach($sDirectory as $mailTemplate) {
if (is_dir($mailTemplate)) {
$inner_files = listFiles($mailTemplate);
if (is_array($inner_files)) $files = array_merge($files, $inner_files);
}
if (is_file($mailTemplate)) {
array_push($files, $mailTemplate);
}
}
foreach($sDirectoryPublic as $publicFile) {
if (is_dir($publicFile)) {
$inner_files = listFiles($publicFile);
if (is_array($inner_files)) $files = array_merge($files, $inner_files);
}
if (is_file($publicFile)) {
array_push($files, $publicFile);
}
}
$sDir = PATH_DATA . "sites/" . $workSpace . "/" . "mailTemplates/";
$sDirPublic = PATH_DATA . "sites/" . $workSpace . "/" . "public/";
foreach ($files as $aFile) {
if (strpos($aFile, $sDir) !== false){
$processUid = current(explode("/", str_replace($sDir,'',$aFile)));
} else {
$processUid = current(explode("/", str_replace($sDirPublic,'',$aFile)));
}
$sql = "SELECT PROCESS_FILES.PRF_PATH FROM PROCESS_FILES WHERE PROCESS_FILES.PRF_PATH='" . $aFile ."'";
$appRows = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
$fileUid = '';
foreach ($appRows as $row) {
$fileUid = $row["PRF_PATH"];
}
if ($fileUid !== $aFile) {
$sPkProcessFiles = G::generateUniqueID();
$sDate = date('Y-m-d H:i:s');
$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)
VALUES ('".$sPkProcessFiles."', '".$processUid."', '00000000000000000000000000000001', '',
'".$aFile."', 'file', 'true', '".$sDate."', NULL)";
$stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
}
}
$con = Propel::getConnection("root");
$stmt = $con->createStatement();
$sDirectory = glob(PATH_DATA . "sites/" . $workSpace . "/" . "mailTemplates/*");
$sDirectoryPublic = glob(PATH_DATA . "sites/" . $workSpace . "/" . "public/*");
$files = array();
foreach($sDirectory as $mailTemplate) {
if (is_dir($mailTemplate)) {
$inner_files = listFiles($mailTemplate);
if (is_array($inner_files)) $files = array_merge($files, $inner_files);
}
if (is_file($mailTemplate)) {
array_push($files, $mailTemplate);
}
}
foreach($sDirectoryPublic as $publicFile) {
if (is_dir($publicFile)) {
$inner_files = listFiles($publicFile);
if (is_array($inner_files)) $files = array_merge($files, $inner_files);
}
if (is_file($publicFile)) {
array_push($files, $publicFile);
}
}
$sDir = PATH_DATA . "sites/" . $workSpace . "/" . "mailTemplates/";
$sDirPublic = PATH_DATA . "sites/" . $workSpace . "/" . "public/";
foreach ($files as $aFile) {
if (strpos($aFile, $sDir) !== false){
$processUid = current(explode("/", str_replace($sDir,'',$aFile)));
} else {
$processUid = current(explode("/", str_replace($sDirPublic,'',$aFile)));
}
$sql = "SELECT PROCESS_FILES.PRF_PATH FROM PROCESS_FILES WHERE PROCESS_FILES.PRF_PATH='" . $aFile ."'";
$appRows = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
$fileUid = '';
foreach ($appRows as $row) {
$fileUid = $row["PRF_PATH"];
}
if ($fileUid !== $aFile) {
$sPkProcessFiles = G::generateUniqueID();
$sDate = date('Y-m-d H:i:s');
$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)
VALUES ('".$sPkProcessFiles."', '".$processUid."', '00000000000000000000000000000001', '',
'".$aFile."', 'file', 'true', '".$sDate."', NULL)";
$stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
}
}
}
/**
@@ -223,7 +223,7 @@ class workspaceTools
}
private function resetDBInfoCallback($matches)
{
{
/* This function changes the values of defines while keeping their formatting
* intact.
* $matches will contain several groups:
@@ -231,7 +231,7 @@ class workspaceTools
*/
$key = isset($matches['key']) ? $matches['key'] : $matches[2];
$value = isset($matches['value']) ? $matches['value'] : $matches[3];
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_');
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");
}
$sDbFile = file_get_contents($this->dbPath);
if ($sDbFile === false) {
throw new Exception("Could not read database information from db.php");
} else {
@@ -296,7 +296,7 @@ class workspaceTools
$this->onedb = true;
}
}
/* Match all defines in the config file. Check updateDBCallback to know what
* keys are changed and what groups are matched.
* This regular expression will match any "define ('<key>', '<value>');"
@@ -540,7 +540,7 @@ class workspaceTools
* @param string $lang not currently used
*/
public function upgradeCacheView($fill = true, $checkOnly = false, $lang = "en")
{
{
$this->initPropel(true);
//require_once ('classes/model/AppCacheView.php');
@@ -554,19 +554,19 @@ class workspaceTools
//setup the appcacheview object, and the path for the sql files
$appCache = new AppCacheView();
$appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP);
$userGrants = $appCache->checkGrantsForUser(false);
$currentUser = $userGrants['user'];
$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 (!$currentUserIsSuper) {
$appCache->checkGrantsForUser(true);
$appCache->setSuperForUser($currentUser);
$currentUserIsSuper = true;
}
CLI::logging("-> Creating tables \n");
//now check if table APPCACHEVIEW exists, and it have correct number of fields, etc.
$res = $appCache->checkAppCacheView();
@@ -574,7 +574,7 @@ class workspaceTools
CLI::logging("-> Update DEL_LAST_INDEX field in APP_DELEGATION table \n");
//Update APP_DELEGATION.DEL_LAST_INDEX data
$res = $appCache->updateAppDelegationDelLastIndex($lang, $checkOnly);
CLI::logging("-> Verifying roles permissions in RBAC \n");
//Update table RBAC permissions
Bootstrap::LoadSystem( 'rbac' );
@@ -758,7 +758,7 @@ class workspaceTools
* @return array bool upgradeSchema for more information
*/
public function upgradeDatabase ($onedb = false, $checkOnly = false)
{
{
G::LoadClass("patch");
$this->initPropel( true );
p11835::$dbAdapter = $this->dbAdapter;
@@ -800,7 +800,7 @@ class workspaceTools
public function upgradeSchema($schema, $checkOnly = false, $rbac = false, $onedb = false)
{
$dbInfo = $this->getDBInfo();
if ($dbInfo['DB_NAME'] == $dbInfo['DB_RBAC_NAME']) {
$onedb = true;
} else {
@@ -1032,7 +1032,7 @@ class workspaceTools
}
$wfDsn = $fields['DB_ADAPTER'] . '://' . $fields['DB_USER'] . ':' . $fields['DB_PASS'] . '@' . $fields['DB_HOST'] . '/' . $fields['DB_NAME'];
$info = array('Workspace Name' => $fields['WORKSPACE_NAME'],
//'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']
@@ -1262,6 +1262,7 @@ class workspaceTools
$lines = explode("\n", $script);
$previous = null;
$insert = false;
foreach ($lines as $j => $line) {
// Remove comments from the script
$line = trim($line);
@@ -1286,6 +1287,7 @@ class workspaceTools
$line = substr($line, 0, strrpos($line, ";"));
if (strrpos($line, "INSERT INTO") !== false) {
$insert = true;
if ($insert) {
$result = mysql_query("START TRANSACTION");
$insert = false;
@@ -1355,7 +1357,7 @@ class workspaceTools
$chmod = @chmod($filename, $perms);
if ($chgrp === false || $chmod === false || $chown === false) {
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 {
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");
}
$workspace = new workspaceTools($workspaceName);
if ($workspace->workspaceExists()) {
if ($overwrite) {
CLI::logging(CLI::warning("> Workspace $workspaceName already exist, overwriting!") . "\n");
} else {
@@ -1489,7 +1491,7 @@ class workspaceTools
if (!$link) {
throw new Exception('Could not connect to system database: ' . mysql_error());
}
$newDBNames = $workspace->resetDBInfo($dbHost, $createWorkspace);
foreach ($metadata->databases as $db) {
@@ -1596,7 +1598,7 @@ class workspaceTools
}
public function checkMafeRequirements ($workspace,$lang) {
$this->initPropel(true);
$this->initPropel(true);
$pmRestClient = OauthClientsPeer::retrieveByPK('x-pm-local-client');
if (empty($pmRestClient)) {
if (is_file(PATH_DATA . 'sites/' . $workspace . '/' . '.server_info')) {