PMC-898
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Validation\MySQL57;
|
||||
|
||||
CLI::taskName('info');
|
||||
CLI::taskDescription(<<<EOT
|
||||
Print information about the current system and any specified workspaces.
|
||||
@@ -372,6 +375,21 @@ EOT
|
||||
);
|
||||
CLI::taskRun("remove_deprecated_files");
|
||||
|
||||
/*********************************************************************/
|
||||
CLI::taskName("check-queries-incompatibilities");
|
||||
CLI::taskDescription(<<<EOT
|
||||
Check queries incompatibilities (MySQL 5.7) for the specified workspace(s).
|
||||
|
||||
This command checks the queries incompatibilities (MySQL 5.7) in the specified workspace(s).
|
||||
|
||||
If no workspace is specified, the command will be run in all workspaces.
|
||||
More than one workspace can be specified.
|
||||
EOT
|
||||
);
|
||||
CLI::taskArg("workspace-name", true, true);
|
||||
CLI::taskRun("run_check_queries_incompatibilities");
|
||||
/*********************************************************************/
|
||||
|
||||
/**
|
||||
* Function run_info
|
||||
*
|
||||
@@ -477,6 +495,7 @@ function run_upgrade_content($args, $opts)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will upgrade the CONTENT table for a workspace
|
||||
* This function is executed only for one workspace
|
||||
@@ -1373,3 +1392,74 @@ function remove_deprecated_files()
|
||||
$workspaceTools->removeDeprecatedFiles();
|
||||
CLI::logging("<*> The deprecated files has been removed. \n");
|
||||
}
|
||||
|
||||
/**
|
||||
* This function review the queries for each workspace or for an specific workspace
|
||||
*
|
||||
* @param array $args
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function run_check_queries_incompatibilities($args)
|
||||
{
|
||||
try {
|
||||
$workspaces = get_workspaces_from_args($args);
|
||||
if (count($args) === 1) {
|
||||
CLI::logging("> Workspace: " . $workspaces[0]->name . PHP_EOL);
|
||||
check_queries_incompatibilities($workspaces[0]->name);
|
||||
} else {
|
||||
foreach ($workspaces as $workspace) {
|
||||
passthru(PHP_BINARY . " processmaker check-queries-incompatibilities " . $workspace->name);
|
||||
}
|
||||
}
|
||||
echo "Done!\n\n";
|
||||
} catch (Exception $e) {
|
||||
G::outRes(CLI::error($e->getMessage()) . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for the incompatibilities in the queries for the specific workspace
|
||||
*
|
||||
* @param string $wsName
|
||||
*/
|
||||
function check_queries_incompatibilities($wsName)
|
||||
{
|
||||
Bootstrap::setConstantsRelatedWs($wsName);
|
||||
require_once(PATH_DB . $wsName . '/db.php');
|
||||
System::initLaravel();
|
||||
|
||||
$query = Process::query()->select('PRO_UID', 'PRO_TITLE');
|
||||
$processesToCheck = $query->get()->values()->toArray();
|
||||
|
||||
$obj = new MySQL57();
|
||||
$resTriggers = $obj->checkIncompatibilityTriggers($processesToCheck);
|
||||
|
||||
if (!empty($resTriggers)) {
|
||||
foreach ($resTriggers as $trigger) {
|
||||
echo ">> The \"" . $trigger['PRO_TITLE'] . "\" process has a trigger called: \"" . $trigger['TRI_TITLE'] . "\" that contains UNION queries. Review the code to discard incompatibilities with MySQL5.7." . PHP_EOL;
|
||||
}
|
||||
} else {
|
||||
echo ">> No MySQL 5.7 incompatibilities in triggers found for this workspace." . PHP_EOL;
|
||||
}
|
||||
|
||||
$resDynaforms = $obj->checkIncompatibilityDynaforms($processesToCheck);
|
||||
|
||||
if (!empty($resDynaforms)) {
|
||||
foreach ($resDynaforms as $dynaform) {
|
||||
echo ">> The \"" . $dynaform['PRO_TITLE'] . "\" process has a dynaform called: \"" . $dynaform['DYN_TITLE'] . "\" that contains UNION queries. Review the code to discard incompatibilities with MySQL5.7." . PHP_EOL;
|
||||
}
|
||||
} else {
|
||||
echo ">> No MySQL 5.7 incompatibilities in dynaforms found for this workspace." . PHP_EOL;
|
||||
}
|
||||
|
||||
$resVariables = $obj->checkIncompatibilityVariables($processesToCheck);
|
||||
|
||||
if (!empty($resVariables)) {
|
||||
foreach ($resVariables as $variable) {
|
||||
echo ">> The \"" . $variable['PRO_TITLE'] . "\" process has a variable called: \"" . $variable['VAR_NAME'] . "\" that contains UNION queries. Review the code to discard incompatibilities with MySQL5.7." . PHP_EOL;
|
||||
}
|
||||
} else {
|
||||
echo ">> No MySQL 5.7 incompatibilities in variables found for this workspace." . PHP_EOL;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user