Merged in release/3.4.8 (pull request #7272)
Updating branch develop with release/3.4.8 Approved-by: Paula Quispe <paula.quispe@processmaker.com> Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
@@ -6075,6 +6075,7 @@ class G
|
||||
|
||||
/**
|
||||
* Add log of execution of triggers
|
||||
*
|
||||
* @param $data
|
||||
* @param string $error
|
||||
* @param string $typeError
|
||||
@@ -6082,24 +6083,22 @@ class G
|
||||
*/
|
||||
public static function logTriggerExecution($data, $error = 'NO-ERROR', $typeError = '', $executionTime = 0)
|
||||
{
|
||||
if ((!empty($data['_CODE_']) || $typeError == 'FATAL_ERROR') && isset($data['_DATA_TRIGGER_']) &&
|
||||
!isset($data['_DATA_TRIGGER_']['_TRI_LOG_'])
|
||||
) {
|
||||
if ((!empty($data['_CODE_']) || $typeError == 'FATAL_ERROR') && empty($data['_DATA_TRIGGER_']['_TRI_LOG_'])) {
|
||||
$lg = Bootstrap::getDefaultContextLog();
|
||||
$lg['TRI_TITLE'] = isset($data['_DATA_TRIGGER_']['TRI_TITLE']) ? $data['_DATA_TRIGGER_']['TRI_TITLE'] : '';
|
||||
$lg['TRI_UID'] = isset($data['_DATA_TRIGGER_']['TRI_UID']) ? $data['_DATA_TRIGGER_']['TRI_UID'] : '';
|
||||
$lg['TRI_CODE'] = isset($data['_DATA_TRIGGER_']['TRI_WEBBOT']) ? $data['_DATA_TRIGGER_']['TRI_WEBBOT'] : '';
|
||||
$lg['TRI_EXECUTION_TIME'] = $executionTime;
|
||||
$lg['TRI_MSG_ERROR'] = $error;
|
||||
$lg['APP_UID'] = isset($data['APPLICATION']) ? $data['APPLICATION'] : '';
|
||||
$lg['PRO_UID'] = isset($data['PROCESS']) ? $data['PROCESS'] : '';
|
||||
$lg['TAS_UID'] = isset($data['TASK']) ? $data['TASK'] : '';
|
||||
$lg['USR_UID'] = isset($data['USER_LOGGED']) ? $data['USER_LOGGED'] : '';
|
||||
$lg['triTitle'] = isset($data['_DATA_TRIGGER_']['TRI_TITLE']) ? $data['_DATA_TRIGGER_']['TRI_TITLE'] : '';
|
||||
$lg['triUid'] = isset($data['_DATA_TRIGGER_']['TRI_UID']) ? $data['_DATA_TRIGGER_']['TRI_UID'] : '';
|
||||
$lg['triCode'] = isset($data['_DATA_TRIGGER_']['TRI_WEBBOT']) ? $data['_DATA_TRIGGER_']['TRI_WEBBOT'] : '';
|
||||
$lg['triExecutionTime'] = $executionTime;
|
||||
$lg['triMessageError'] = $error;
|
||||
$lg['appUid'] = isset($data['APPLICATION']) ? $data['APPLICATION'] : '';
|
||||
$lg['proUid'] = isset($data['PROCESS']) ? $data['PROCESS'] : '';
|
||||
$lg['tasUid'] = isset($data['TASK']) ? $data['TASK'] : '';
|
||||
$lg['usrUid'] = isset($data['USER_LOGGED']) ? $data['USER_LOGGED'] : '';
|
||||
|
||||
Bootstrap::registerMonolog(
|
||||
(empty($sError)) ? 'TriggerExecution' : 'TriggerExecutionError',
|
||||
(empty($sError)) ? 200 : 400,
|
||||
(empty($sError)) ? 'Trigger Execution' : 'Trigger Execution Error',
|
||||
(empty($error)) ? 'TriggerExecution' : 'TriggerExecutionError',
|
||||
(empty($error)) ? 200 : 400,
|
||||
(empty($error)) ? 'Trigger Execution' : 'Trigger Execution Error',
|
||||
$lg,
|
||||
$lg['workspace'],
|
||||
'processmaker.log'
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
namespace Tests\unit\gulliver\system;
|
||||
|
||||
use G;
|
||||
use MonologProvider;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \G
|
||||
*/
|
||||
class gTest extends TestCase
|
||||
{
|
||||
/**
|
||||
@@ -350,4 +354,27 @@ class gTest extends TestCase
|
||||
$this->assertContains($word, $res);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests if the errors related to the trigger execution was registered
|
||||
*
|
||||
* @covers ::logTriggerExecution
|
||||
* @test
|
||||
*/
|
||||
public function it_check_log_trigger_execution()
|
||||
{
|
||||
$data = [];
|
||||
$error = 'This is some error';
|
||||
$_SESSION['_DATA_TRIGGER_']['_TRI_LOG_'] = false;
|
||||
G::logTriggerExecution($data, $error, 'FATAL_ERROR', 60);
|
||||
$log = MonologProvider::getSingleton('TriggerExecutionError', 'processmaker.log', true);
|
||||
$this->assertNotEmpty($log->getPathFile());
|
||||
$this->assertTrue($_SESSION['_DATA_TRIGGER_']['_TRI_LOG_']);
|
||||
|
||||
$_SESSION['_DATA_TRIGGER_']['_TRI_LOG_'] = false;
|
||||
G::logTriggerExecution($data, '', '', 100);
|
||||
$log = MonologProvider::getSingleton('TriggerExecution', 'processmaker.log', true);
|
||||
$this->assertNotEmpty($log->getPathFile());
|
||||
$this->assertFalse($_SESSION['_DATA_TRIGGER_']['_TRI_LOG_']);
|
||||
}
|
||||
}
|
||||
@@ -111,6 +111,16 @@ class SpoolRun
|
||||
return $this->spoolId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the fileData property
|
||||
*
|
||||
* @param array $fileData
|
||||
*/
|
||||
public function setFileData($fileData)
|
||||
{
|
||||
$this->fileData = $fileData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fileData property
|
||||
*
|
||||
|
||||
@@ -1007,10 +1007,21 @@ class WsBase
|
||||
|
||||
$result = "";
|
||||
if ($gmail != 1) {
|
||||
$closure = function() use ($setup, $messageArray, $gmail, $to) {
|
||||
// Create always the record in APP_MESSAGE table
|
||||
$spool = new SpoolRun();
|
||||
$spool->setConfig($setup);
|
||||
$spool->create($messageArray);
|
||||
|
||||
// Get the data of the record created
|
||||
$fileData = $spool->getFileData();
|
||||
$fileData['spoolId'] = $spool->getSpoolId();
|
||||
|
||||
// Create the closure and send the required data
|
||||
$closure = function() use ($setup, $fileData, $gmail, $to) {
|
||||
$spool = new SpoolRun();
|
||||
$spool->setConfig($setup);
|
||||
$spool->setSpoolId($fileData['spoolId']);
|
||||
$spool->setFileData($fileData);
|
||||
$spool->sendMail();
|
||||
return $spool;
|
||||
};
|
||||
|
||||
@@ -190,6 +190,7 @@ class JobsManager
|
||||
$callback($environment);
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage() . ": " . $e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
});
|
||||
$instance->delay($this->delay);
|
||||
|
||||
Reference in New Issue
Block a user