HOR-4408
This commit is contained in:
@@ -46,11 +46,12 @@ function run_addon_core_install($args)
|
||||
$storeId = $args[1];
|
||||
$addonName = $args[2];
|
||||
|
||||
if (!defined("SYS_SYS")) {
|
||||
if (empty(config("system.workspace"))) {
|
||||
define("SYS_SYS", $workspace);
|
||||
config(["system.workspace" => $workspace]);
|
||||
}
|
||||
if (!defined("PATH_DATA_SITE")) {
|
||||
define("PATH_DATA_SITE", PATH_DATA . "sites/" . SYS_SYS . "/");
|
||||
define("PATH_DATA_SITE", PATH_DATA . "sites/" . config("system.workspace") . "/");
|
||||
}
|
||||
if (!defined("DB_ADAPTER")) {
|
||||
define("DB_ADAPTER", $args[3]);
|
||||
@@ -102,11 +103,12 @@ function change_hash($command, $opts)
|
||||
$response = new stdclass();
|
||||
$response->workspace = $workspace;
|
||||
$response->hash = $hash;
|
||||
if (!defined("SYS_SYS")) {
|
||||
if (empty(config("system.workspace"))) {
|
||||
define("SYS_SYS", $workspace->name);
|
||||
config(["system.workspace" => $workspace->name]);
|
||||
}
|
||||
if (!defined("PATH_DATA_SITE")) {
|
||||
define("PATH_DATA_SITE", PATH_DATA . "sites/" . SYS_SYS . "/");
|
||||
define("PATH_DATA_SITE", PATH_DATA . "sites/" . config("system.workspace") . "/");
|
||||
}
|
||||
$_SESSION['__sw__'] = '';
|
||||
if (!$workspace->changeHashPassword($workspace->name, $response)) {
|
||||
|
||||
@@ -132,12 +132,13 @@ function run_upgrade($command, $args)
|
||||
$flagUpdateXml = !array_key_exists('noxml', $args);
|
||||
|
||||
foreach ($workspaces as $index => $workspace) {
|
||||
if (!defined("SYS_SYS")) {
|
||||
if (empty(config("system.workspace"))) {
|
||||
define("SYS_SYS", $workspace->name);
|
||||
config(["system.workspace" => $workspace->name]);
|
||||
}
|
||||
|
||||
if (!defined("PATH_DATA_SITE")) {
|
||||
define("PATH_DATA_SITE", PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP);
|
||||
define("PATH_DATA_SITE", PATH_DATA . "sites" . PATH_SEP . config("system.workspace") . PATH_SEP);
|
||||
}
|
||||
|
||||
if(!defined('DB_ADAPTER')) {
|
||||
|
||||
@@ -315,6 +315,17 @@ CLI::taskOpt("lang", "", "lLANG", "lang=LANG");
|
||||
CLI::taskArg('workspace');
|
||||
CLI::taskRun("cliListIds");
|
||||
|
||||
/**
|
||||
* Upgrade the CONTENT table
|
||||
*/
|
||||
CLI::taskName('upgrade-content');
|
||||
CLI::taskDescription(<<<EOT
|
||||
Upgrade the content table
|
||||
EOT
|
||||
);
|
||||
CLI::taskArg('workspace');
|
||||
CLI::taskRun("run_upgrade_content");
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -345,28 +356,61 @@ function run_info($args, $opts)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we need to execute the workspace-upgrade
|
||||
* If we apply the command for all workspaces, we will need to execute one by one by redefining the constants
|
||||
*
|
||||
* @param string $args, workspace name that we need to apply the database-upgrade
|
||||
* @param string $opts, additional arguments
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function run_workspace_upgrade($args, $opts)
|
||||
{
|
||||
$filter = new InputFilter();
|
||||
$opts = $filter->xssFilterHard($opts);
|
||||
$args = $filter->xssFilterHard($args);
|
||||
$workspaces = get_workspaces_from_args($args);
|
||||
//Read the additional parameters for this command
|
||||
$parameters = '';
|
||||
$parameters .= array_key_exists('buildACV', $opts) ? '--buildACV ' : '';
|
||||
$parameters .= array_key_exists('noxml', $opts) ? '--no-xml ' : '';
|
||||
$parameters .= array_key_exists("lang", $opts) ? 'lang=' . $opts['lang'] : 'lang=' . SYS_LANG;
|
||||
|
||||
//Check if the command is executed by a specific workspace
|
||||
if (count($args) === 1) {
|
||||
workspace_upgrade($args, $opts);
|
||||
} else {
|
||||
$workspaces = get_workspaces_from_args($args);
|
||||
foreach ($workspaces as $workspace) {
|
||||
passthru('./processmaker upgrade ' . $parameters . ' ' . $workspace->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is executed only by one workspace, for the command workspace-upgrade
|
||||
*
|
||||
* @param array $args, workspace name for to apply the upgrade
|
||||
* @param array $opts, specify additional arguments for language, flag for buildACV, flag for noxml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function workspace_upgrade($args, $opts) {
|
||||
$first = true;
|
||||
$workspaces = get_workspaces_from_args($args);
|
||||
$lang = array_key_exists("lang", $opts) ? $opts['lang'] : 'en';
|
||||
$buildCacheView = array_key_exists('buildACV', $opts);
|
||||
$flagUpdateXml = !array_key_exists('noxml', $opts);
|
||||
|
||||
$wsName = $workspaces[key($workspaces)]->name;
|
||||
Bootstrap::setConstantsRelatedWs($wsName);
|
||||
//Loop, read all the attributes related to the one workspace
|
||||
foreach ($workspaces as $workspace) {
|
||||
try {
|
||||
if (!defined("SYS_SYS")) {
|
||||
define("SYS_SYS", $workspace->name);
|
||||
}
|
||||
|
||||
if (!defined("PATH_DATA_SITE")) {
|
||||
define("PATH_DATA_SITE", PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP);
|
||||
}
|
||||
|
||||
$workspace->upgrade($buildCacheView, $workspace->name, false, $lang, ['updateXml' => $flagUpdateXml, 'updateMafe' => $first]);
|
||||
$workspace->upgrade(
|
||||
$buildCacheView,
|
||||
$workspace->name,
|
||||
false,
|
||||
$lang,
|
||||
['updateXml' => $flagUpdateXml, 'updateMafe' => $first]
|
||||
);
|
||||
$first = false;
|
||||
$flagUpdateXml = false;
|
||||
} catch (Exception $e) {
|
||||
@@ -375,6 +419,56 @@ function run_workspace_upgrade($args, $opts)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We will upgrade the CONTENT table
|
||||
* If we apply the command for all workspaces, we will need to execute one by one by redefining the constants
|
||||
* @param string $args, workspaceName that we need to apply the upgrade-content
|
||||
* @param string $opts
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function run_upgrade_content($args, $opts)
|
||||
{
|
||||
//Check if the command is executed by a specific workspace
|
||||
if (count($args) === 1) {
|
||||
upgradeContent($args, $opts);
|
||||
} else {
|
||||
$workspaces = get_workspaces_from_args($args);
|
||||
foreach ($workspaces as $workspace) {
|
||||
passthru('./processmaker upgrade-content ' . $workspace->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* This function will upgrade the CONTENT table for a workspace
|
||||
* This function is executed only for one workspace
|
||||
* @param array $args, workspaceName that we will to apply the command
|
||||
* @param array $opts, we can send additional parameters
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function upgradeContent($args, $opts)
|
||||
{
|
||||
try {
|
||||
//Load the attributes for the workspace
|
||||
$arrayWorkspace = get_workspaces_from_args($args);
|
||||
//Loop, read all the attributes related to the one workspace
|
||||
$wsName = $arrayWorkspace[key($arrayWorkspace)]->name;
|
||||
Bootstrap::setConstantsRelatedWs($wsName);
|
||||
$workspaces = get_workspaces_from_args($args);
|
||||
foreach ($workspaces as $workspace) {
|
||||
try {
|
||||
G::outRes("Upgrading content for " . pakeColor::colorize($workspace->name, "INFO") . "\n");
|
||||
$workspace->upgradeContent($workspace->name, true);
|
||||
} catch (Exception $e) {
|
||||
G::outRes("Errors upgrading content of workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n");
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
G::outRes(CLI::error($e->getMessage()) . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We will repair the translation in the languages defined in the workspace
|
||||
* Verify if we need to execute an external program for each workspace
|
||||
|
||||
Reference in New Issue
Block a user