This commit is contained in:
Julio Cesar Laura Avendaño
2019-04-23 09:42:25 -04:00
parent 357fd58e0e
commit 5d866a859f
2 changed files with 152 additions and 113 deletions

View File

@@ -94,11 +94,21 @@ class MultipleFilesBackup
} }
} }
/* Restore from file(s) commpressed by letsBackup function, into a temporary directory /**
* @ filename got the name and path of the compressed file(s), if there are many files with file extention as a numerical series, the extention should be discriminated. * Restore from file(s) compressed by letsBackup function, into a temporary directory
* @ srcWorkspace contains the workspace to be restored. *
* @ dstWorkspace contains the workspace to be overwriting. * @param string $filename Got the name and path of the compressed file(s), if there are many files with file extention as a numerical series, the extention should be discriminated.
* @ overwrite got the option true if the workspace will be overwrite. * @param string $srcWorkspace Contains the workspace to be restored.
* @param bool $dstWorkspace Contains the workspace to be overwriting.
* @param bool $overwrite Got the option true if the workspace will be overwrite.
*
* @throws Exception
*
* @see workflow/engine/bin/tasks/cliWorkspaces.php::run_workspace_restore()
*
* @link https://wiki.processmaker.com/3.0/Backing_up_and_Restoring_ProcessMaker#RestoringWorkspaces
*
* @deprecated Method outdated, only run the upgrade of APP_CACHE_VIEW table
*/ */
public static function letsRestore($filename, $srcWorkspace, $dstWorkspace = null, $overwrite = true) public static function letsRestore($filename, $srcWorkspace, $dstWorkspace = null, $overwrite = true)
{ {

View File

@@ -66,6 +66,23 @@ class WorkspaceTools
'UPDATE LIST_UNASSIGNED_GROUP SET 'UPDATE LIST_UNASSIGNED_GROUP SET
USR_ID=(SELECT USR_ID FROM USERS WHERE USERS.USR_UID=LIST_UNASSIGNED_GROUP.USR_UID)', USR_ID=(SELECT USR_ID FROM USERS WHERE USERS.USR_UID=LIST_UNASSIGNED_GROUP.USR_UID)',
); );
public static $triggers = [
'APP_DELEGATION_UPDATE',
'APPLICATION_UPDATE',
'CONTENT_UPDATE'
];
public static $bigTables = [
'APPLICATION',
'APP_ASSIGN_SELF_SERVICE_VALUE_GROUP',
'APP_CACHE_VIEW',
'APP_DELEGATION',
'APP_DELAY',
'APP_DOCUMENT',
'APP_HISTORY',
'APP_MESSAGE',
'GROUP_USER',
'LOGIN_LOG'
];
private $lastContentMigrateTable = false; private $lastContentMigrateTable = false;
private $listContentMigrateTable = []; private $listContentMigrateTable = [];
@@ -249,18 +266,16 @@ class WorkspaceTools
$this->checkMafeRequirements($workspace, $lang); $this->checkMafeRequirements($workspace, $lang);
CLI::logging("* End checking MAFE requirements...(Completed on " . (microtime(true) - $start) . " seconds)\n"); CLI::logging("* End checking MAFE requirements...(Completed on " . (microtime(true) - $start) . " seconds)\n");
CLI::logging("* Start deleting MySQL triggers: APP_DELEGATION_UPDATE, APPLICATION_UPDATE, CONTENT_UPDATE...\n"); CLI::logging("* Start deleting MySQL triggers: " . implode(', ', self::$triggers) . "...\n");
$start = microtime(true); $start = microtime(true);
$this->deleteTriggersMySQL(['APP_DELEGATION_UPDATE', 'APPLICATION_UPDATE', 'CONTENT_UPDATE']); $this->deleteTriggersMySQL(self::$triggers);
CLI::logging("* End deleting MySQL triggers: APP_DELEGATION_UPDATE, APPLICATION_UPDATE, CONTENT_UPDATE... (Completed on " . CLI::logging("* End deleting MySQL triggers: " . implode(', ', self::$triggers) . "... (Completed on " .
(microtime(true) - $start) . " seconds)\n"); (microtime(true) - $start) . " seconds)\n");
$bigTables = ['APPLICATION', 'APP_ASSIGN_SELF_SERVICE_VALUE_GROUP', 'APP_CACHE_VIEW', 'APP_DELEGATION', 'APP_DELAY', CLI::logging("* Start deleting indexes from big tables: " . implode(', ', self::$bigTables) . "...\n");
'APP_DOCUMENT', 'APP_HISTORY', 'APP_MESSAGE', 'GROUP_USER', 'LOGIN_LOG'];
CLI::logging("* Start deleting indexes from big tables: " . implode(', ', $bigTables) . "...\n");
$start = microtime(true); $start = microtime(true);
$this->deleteIndexes($bigTables); $this->deleteIndexes(self::$bigTables);
CLI::logging("* End deleting indexes from big tables: " . implode(', ', $bigTables) . "... (Completed on " . CLI::logging("* End deleting indexes from big tables: " . implode(', ', self::$bigTables) . "... (Completed on " .
(microtime(true) - $start) . " seconds)\n"); (microtime(true) - $start) . " seconds)\n");
CLI::logging("* Start to update CONTENT table...\n"); CLI::logging("* Start to update CONTENT table...\n");
@@ -1854,7 +1869,7 @@ class WorkspaceTools
} }
/** /**
* restore an archive into a workspace * Restore a workspace
* *
* Restores any database and files included in the backup, either as a new * Restores any database and files included in the backup, either as a new
* workspace, or overwriting a previous one * workspace, or overwriting a previous one
@@ -1865,8 +1880,13 @@ class WorkspaceTools
* @param boolean $overwrite if you need overwrite the database * @param boolean $overwrite if you need overwrite the database
* @param string $lang for define the language * @param string $lang for define the language
* @param string $port of database if is empty take 3306 * @param string $port of database if is empty take 3306
* @param array $optionMigrateHistoryData
* *
* @throws Exception * @throws Exception
*
* @see workflow/engine/bin/tasks/cliWorkspaces.php::run_workspace_restore()
*
* @link https://wiki.processmaker.com/3.0/Backing_up_and_Restoring_ProcessMaker#RestoringWorkspaces
*/ */
public static function restore($filename, $srcWorkspace, $dstWorkspace = null, $overwrite = true, $lang = 'en', $port = '', $optionMigrateHistoryData = []) public static function restore($filename, $srcWorkspace, $dstWorkspace = null, $overwrite = true, $lang = 'en', $port = '', $optionMigrateHistoryData = [])
{ {
@@ -2034,115 +2054,124 @@ class WorkspaceTools
} }
} }
$start = microtime(true); if (empty($pmVersion) && strpos(strtoupper($version), 'BRANCH')) {
CLI::logging("> Remove deprecated files...\n");
$workspace->removeDeprecatedFiles();
$stop = microtime(true);
CLI::logging("<*> Remove deprecated files took " . ($stop - $start) . " seconds.\n");
if (($pmVersionWorkspaceToRestore != '') && (version_compare(
$pmVersionWorkspaceToRestore . "",
$pmVersion . "",
"<"
) || $pmVersion == "")
) {
$start = microtime(true);
CLI::logging("> Updating database...\n");
$workspace->upgradeDatabase($onedb);
$stop = microtime(true);
CLI::logging("<*> Database Upgrade Process took " . ($stop - $start) . " seconds.\n");
}
$start = microtime(true);
CLI::logging("> Verify files enterprise old...\n");
$workspace->verifyFilesOldEnterprise($workspaceName);
$stop = microtime(true);
CLI::logging("<*> Verify took " . ($stop - $start) . " seconds.\n");
$start = microtime(true);
CLI::logging("> Verify License Enterprise...\n");
$workspace->verifyLicenseEnterprise($workspaceName);
$stop = microtime(true);
CLI::logging("<*> Verify took " . ($stop - $start) . " seconds.\n");
$start = microtime(true);
CLI::logging("> Check Mafe Requirements...\n");
$workspace->checkMafeRequirements($workspaceName, $lang);
$stop = microtime(true);
CLI::logging("<*> Check Mafe Requirements Process took " . ($stop - $start) . " seconds.\n");
if (($pmVersionWorkspaceToRestore != '') && (version_compare(
$pmVersionWorkspaceToRestore . "",
$pmVersion . "",
"<"
) || $pmVersion == "")
) {
$start = microtime(true);
CLI::logging("> Updating cache view...\n");
$workspace->upgradeCacheView(true, true, $lang);
$stop = microtime(true);
CLI::logging("<*> Updating cache view Process took " . ($stop - $start) . " seconds.\n");
} else {
$workspace->upgradeTriggersOfTables(true, $lang);
}
if ($pmVersion == '' && strpos(strtoupper($version), 'BRANCH')) {
$pmVersion = 'dev-version-backup'; $pmVersion = 'dev-version-backup';
} }
//Move the labels of content to the corresponding table if (!empty($pmVersionWorkspaceToRestore) && (version_compare(
$pmVersionWorkspaceToRestore . "",
$pmVersion . "",
"<"
) || empty($pmVersion)) || $pmVersion == "dev-version-backup"
) {
// Upgrade the database schema and data
CLI::logging("* Start updating database schema...\n");
$start = microtime(true); $start = microtime(true);
CLI::logging("> Optimizing content data...\n"); $workspace->upgradeDatabase();
$workspace->migrateContent($workspace->name, $lang); CLI::logging("* End updating database schema...(Completed on " . (microtime(true) - $start) . " seconds)\n");
$stop = microtime(true);
CLI::logging("<*> Optimizing content data took " . ($stop - $start) . " seconds.\n");
//Populate the new fields for replace string UID to Interger ID CLI::logging("* Start checking MAFE requirements...\n");
$start = microtime(true); $start = microtime(true);
CLI::logging("> Migrating and populating indexing for APP_CACHE_VIEW...\n"); $workspace->checkMafeRequirements($workspaceName, $lang);
$workspace->migratePopulateIndexingACV($workspace->name); CLI::logging("* End checking MAFE requirements...(Completed on " . (microtime(true) - $start) . " seconds)\n");
$stop = microtime(true);
CLI::logging("<*> Migrating an populating indexing for APP_CACHE_VIEW process took " . ($stop - $start) . " seconds.\n");
//Move the data of cases to the corresponding List CLI::logging("* Start deleting MySQL triggers: " . implode(', ', self::$triggers) . "...\n");
/*----------------------------------********---------------------------------*/
$start = microtime(true); $start = microtime(true);
CLI::logging("> Updating List tables...\n"); $workspace->deleteTriggersMySQL(self::$triggers);
$workspace->migrateList($workspace->name, false, $lang); CLI::logging("* End deleting MySQL triggers: " . implode(', ', self::$triggers) . "... (Completed on " .
$stop = microtime(true); (microtime(true) - $start) . " seconds)\n");
CLI::logging("<*> Updating List Process took " . ($stop - $start) . " seconds.\n");
/*----------------------------------********---------------------------------*/ CLI::logging("* Start deleting indexes from big tables: " . implode(', ', self::$bigTables) . "...\n");
$start = microtime(true);
$workspace->deleteIndexes(self::$bigTables);
CLI::logging("* End deleting indexes from big tables: " . implode(', ', self::$bigTables) . "... (Completed on " .
(microtime(true) - $start) . " seconds)\n");
$start = microtime(true); $start = microtime(true);
CLI::logging("> Updating Files Manager...\n"); CLI::logging("* Start to migrate texts/values from 'CONTENT' table to the corresponding object tables...\n");
$workspace->processFilesUpgrade(); $workspace->migrateContent($lang);
$stop = microtime(true); CLI::logging("* End to migrate texts/values from 'CONTENT' table to the corresponding object tables... (Completed on " .
CLI::logging("<*> Updating Files Manager took " . ($stop - $start) . " seconds.\n"); (microtime(true) - $start) . " seconds)\n");
//Updating generated class files for PM Tables CLI::logging("* Start updating rows in Web Entry table for classic processes...\n");
passthru(PHP_BINARY . ' processmaker regenerate-pmtable-classes ' . $workspace->name); $start = microtime(true);
$workspace->updatingWebEntryClassicModel(true);
CLI::logging("* End updating rows in Web Entry table for classic processes...(Completed on " .
(microtime(true) - $start) . " seconds)\n");
CLI::logging("* Start to update Files Manager...\n");
$start = microtime(true);
$workspace->processFilesUpgrade($workspaceName);
CLI::logging("* End to update Files Manager... (Completed on " . (microtime(true) - $start) . " seconds)\n");
CLI::logging("* Start migrating and populating plugin singleton data...\n");
$start = microtime(true);
$workspace->migrateSingleton($workspaceName);
CLI::logging("* End migrating and populating plugin singleton data...(Completed on " .
(microtime(true) - $start) . " seconds)\n");
CLI::logging("* Start to check Intermediate Email Event...\n");
$start = microtime(true);
$workspace->checkIntermediateEmailEvent();
CLI::logging("* End to check Intermediate Email Event... (Completed on " . (microtime(true) - $start) . " seconds)\n");
CLI::logging("* Start cleaning DYN_CONTENT in APP_HISTORY...\n");
$start = microtime(true);
$keepDynContent = isset($optionMigrateHistoryData['keepDynContent']) && $optionMigrateHistoryData['keepDynContent'] === true; $keepDynContent = isset($optionMigrateHistoryData['keepDynContent']) && $optionMigrateHistoryData['keepDynContent'] === true;
//Review if we need to remove the 'History of use' from APP_HISTORY
$start = microtime(true);
CLI::logging("> Clearing History of Use from APP_HISTORY table...\n");
$workspace->clearDynContentHistoryData(false, $keepDynContent); $workspace->clearDynContentHistoryData(false, $keepDynContent);
$stop = microtime(true); CLI::logging("* End cleaning DYN_CONTENT in APP_HISTORY...(Completed on " . (microtime(true) - $start) . " seconds)\n");
CLI::logging("<*> Clearing History of Use from APP_HISTORY table took " . ($stop - $start) . " seconds.\n");
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
CLI::logging("* Start migrating history data...\n");
$start = microtime(true); $start = microtime(true);
CLI::logging("> Migrating history data...\n");
$workspace->migrateAppHistoryToAppDataChangeLog(false); $workspace->migrateAppHistoryToAppDataChangeLog(false);
$stop = microtime(true); CLI::logging("* End migrating history data...(Completed on " . (microtime(true) - $start) . " seconds)\n");
CLI::logging("<*> Migrating history data took " . ($stop - $start) . " seconds.\n");
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
CLI::logging("* Start migrating and populating indexing for avoiding the use of table APP_CACHE_VIEW...\n");
$start = microtime(true);
$workspace->migratePopulateIndexingACV();
CLI::logging("* End migrating and populating indexing for avoiding the use of table APP_CACHE_VIEW...(Completed on " .
(microtime(true) - $start) . " seconds)\n");
CLI::logging("* Start optimizing Self-Service data in table APP_ASSIGN_SELF_SERVICE_VALUE_GROUP....\n");
$start = microtime(true);
$workspace->migrateSelfServiceRecordsRun();
CLI::logging("* End optimizing Self-Service data in table APP_ASSIGN_SELF_SERVICE_VALUE_GROUP....(Completed on " .
(microtime(true) - $start) . " seconds)\n");
CLI::logging("* Start adding new fields and populating values in tables related to feature self service by value...\n");
$start = microtime(true); $start = microtime(true);
CLI::logging("> Optimizing Self-Service data in table APP_ASSIGN_SELF_SERVICE_VALUE_GROUP....\n");
$workspace->upgradeSelfServiceData(); $workspace->upgradeSelfServiceData();
$stop = microtime(true); CLI::logging("* End adding new fields and populating values in tables related to feature self service by value...(Completed on " .
CLI::logging("<*> Optimizing Self-Service data in table APP_ASSIGN_SELF_SERVICE_VALUE_GROUP took " . ($stop - $start) . " seconds.\n"); (microtime(true) - $start) . " seconds)\n");
CLI::logging("* Start adding/replenishing all indexes...\n");
$start = microtime(true);
$systemSchema = System::getSystemSchema($workspace->dbAdapter);
$workspace->upgradeSchema($systemSchema);
CLI::logging("* End adding/replenishing all indexes...(Completed on " . (microtime(true) - $start) . " seconds)\n");
/*----------------------------------********---------------------------------*/
CLI::logging("* Start migrating to new list tables...\n");
$start = microtime(true);
$workspace->migrateList(true, $lang);
CLI::logging("* End migrating to new list tables...(Completed on " . (microtime(true) - $start) . " seconds)\n");
/*----------------------------------********---------------------------------*/
CLI::logging("* Start updating MySQL triggers...\n");
$start = microtime(true);
$workspace->updateTriggers(true, $lang);
CLI::logging("* End updating MySQL triggers...(" . (microtime(true) - $start) . " seconds)\n");
}
CLI::logging("> Start To Verify License Enterprise...\n");
$start = microtime(true);
$workspace->verifyLicenseEnterprise($workspaceName);
CLI::logging("* End To Verify License Enterprise...(" . (microtime(true) - $start) . " seconds)\n");
// Updating generated class files for PM Tables
passthru(PHP_BINARY . ' processmaker regenerate-pmtable-classes ' . $workspaceName);
} }
CLI::logging("Removing temporary files\n"); CLI::logging("Removing temporary files\n");
@@ -2318,7 +2347,7 @@ class WorkspaceTools
CLI::logging(" Migrating Enterprise Core version...\n"); CLI::logging(" Migrating Enterprise Core version...\n");
if (!file_exists($pathNewFile)) { if (!file_exists($pathNewFile)) {
CLI::logging(" Creating folder in $pathNewFile\n"); CLI::logging(" Creating folder in $pathNewFile\n");
G::mk_dir($newDiretory, 0777); G::mk_dir($pathNewFile, 0777);
} }
$shared_stat = stat(PATH_DATA); $shared_stat = stat(PATH_DATA);
if (file_exists($pathDirectoryEnterprise)) { if (file_exists($pathDirectoryEnterprise)) {