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
|
* Add log of execution of triggers
|
||||||
|
*
|
||||||
* @param $data
|
* @param $data
|
||||||
* @param string $error
|
* @param string $error
|
||||||
* @param string $typeError
|
* @param string $typeError
|
||||||
@@ -6082,24 +6083,22 @@ class G
|
|||||||
*/
|
*/
|
||||||
public static function logTriggerExecution($data, $error = 'NO-ERROR', $typeError = '', $executionTime = 0)
|
public static function logTriggerExecution($data, $error = 'NO-ERROR', $typeError = '', $executionTime = 0)
|
||||||
{
|
{
|
||||||
if ((!empty($data['_CODE_']) || $typeError == 'FATAL_ERROR') && isset($data['_DATA_TRIGGER_']) &&
|
if ((!empty($data['_CODE_']) || $typeError == 'FATAL_ERROR') && empty($data['_DATA_TRIGGER_']['_TRI_LOG_'])) {
|
||||||
!isset($data['_DATA_TRIGGER_']['_TRI_LOG_'])
|
|
||||||
) {
|
|
||||||
$lg = Bootstrap::getDefaultContextLog();
|
$lg = Bootstrap::getDefaultContextLog();
|
||||||
$lg['TRI_TITLE'] = isset($data['_DATA_TRIGGER_']['TRI_TITLE']) ? $data['_DATA_TRIGGER_']['TRI_TITLE'] : '';
|
$lg['triTitle'] = 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['triUid'] = 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['triCode'] = isset($data['_DATA_TRIGGER_']['TRI_WEBBOT']) ? $data['_DATA_TRIGGER_']['TRI_WEBBOT'] : '';
|
||||||
$lg['TRI_EXECUTION_TIME'] = $executionTime;
|
$lg['triExecutionTime'] = $executionTime;
|
||||||
$lg['TRI_MSG_ERROR'] = $error;
|
$lg['triMessageError'] = $error;
|
||||||
$lg['APP_UID'] = isset($data['APPLICATION']) ? $data['APPLICATION'] : '';
|
$lg['appUid'] = isset($data['APPLICATION']) ? $data['APPLICATION'] : '';
|
||||||
$lg['PRO_UID'] = isset($data['PROCESS']) ? $data['PROCESS'] : '';
|
$lg['proUid'] = isset($data['PROCESS']) ? $data['PROCESS'] : '';
|
||||||
$lg['TAS_UID'] = isset($data['TASK']) ? $data['TASK'] : '';
|
$lg['tasUid'] = isset($data['TASK']) ? $data['TASK'] : '';
|
||||||
$lg['USR_UID'] = isset($data['USER_LOGGED']) ? $data['USER_LOGGED'] : '';
|
$lg['usrUid'] = isset($data['USER_LOGGED']) ? $data['USER_LOGGED'] : '';
|
||||||
|
|
||||||
Bootstrap::registerMonolog(
|
Bootstrap::registerMonolog(
|
||||||
(empty($sError)) ? 'TriggerExecution' : 'TriggerExecutionError',
|
(empty($error)) ? 'TriggerExecution' : 'TriggerExecutionError',
|
||||||
(empty($sError)) ? 200 : 400,
|
(empty($error)) ? 200 : 400,
|
||||||
(empty($sError)) ? 'Trigger Execution' : 'Trigger Execution Error',
|
(empty($error)) ? 'Trigger Execution' : 'Trigger Execution Error',
|
||||||
$lg,
|
$lg,
|
||||||
$lg['workspace'],
|
$lg['workspace'],
|
||||||
'processmaker.log'
|
'processmaker.log'
|
||||||
|
|||||||
@@ -3,8 +3,12 @@
|
|||||||
namespace Tests\unit\gulliver\system;
|
namespace Tests\unit\gulliver\system;
|
||||||
|
|
||||||
use G;
|
use G;
|
||||||
|
use MonologProvider;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @coversDefaultClass \G
|
||||||
|
*/
|
||||||
class gTest extends TestCase
|
class gTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -350,4 +354,27 @@ class gTest extends TestCase
|
|||||||
$this->assertContains($word, $res);
|
$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;
|
return $this->spoolId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the fileData property
|
||||||
|
*
|
||||||
|
* @param array $fileData
|
||||||
|
*/
|
||||||
|
public function setFileData($fileData)
|
||||||
|
{
|
||||||
|
$this->fileData = $fileData;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the fileData property
|
* Get the fileData property
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1007,10 +1007,21 @@ class WsBase
|
|||||||
|
|
||||||
$result = "";
|
$result = "";
|
||||||
if ($gmail != 1) {
|
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 = new SpoolRun();
|
||||||
$spool->setConfig($setup);
|
$spool->setConfig($setup);
|
||||||
$spool->create($messageArray);
|
$spool->setSpoolId($fileData['spoolId']);
|
||||||
|
$spool->setFileData($fileData);
|
||||||
$spool->sendMail();
|
$spool->sendMail();
|
||||||
return $spool;
|
return $spool;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -190,6 +190,7 @@ class JobsManager
|
|||||||
$callback($environment);
|
$callback($environment);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Log::error($e->getMessage() . ": " . $e->getTraceAsString());
|
Log::error($e->getMessage() . ": " . $e->getTraceAsString());
|
||||||
|
throw $e;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$instance->delay($this->delay);
|
$instance->delay($this->delay);
|
||||||
|
|||||||
Reference in New Issue
Block a user