Merged in bugfix/PMC-748 (pull request #6871)
PMC-748 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
@@ -3541,19 +3541,19 @@ class Cases
|
|||||||
*/
|
*/
|
||||||
if ($oPMScript->executedOn() === $oPMScript::AFTER_ROUTING) {
|
if ($oPMScript->executedOn() === $oPMScript::AFTER_ROUTING) {
|
||||||
//Get the variables changed with the trigger
|
//Get the variables changed with the trigger
|
||||||
$fieldsTrigger = arrayDiffRecursive($appDataAfterTrigger, $fieldsCase);
|
$fieldsTrigger = getDiffBetweenModifiedVariables($appDataAfterTrigger, $fieldsCase);
|
||||||
|
$collection = collect($fieldsCase);
|
||||||
|
$merged = $collection->merge($fieldsTrigger);
|
||||||
|
//Merge the appData with variables changed
|
||||||
|
$fieldsCase = $merged->all();
|
||||||
|
|
||||||
//We will be load the last appData because:
|
//We will be load the last appData because:
|
||||||
//Other thread execution can be changed the variables
|
//Other thread execution can be changed the variables
|
||||||
$appUid = !empty($fieldsCase['APPLICATION']) ? $fieldsCase['APPLICATION'] : '';
|
$appUid = !empty($fieldsCase['APPLICATION']) ? $fieldsCase['APPLICATION'] : '';
|
||||||
|
|
||||||
//Save the fields changed in the trigger
|
//Save the fields changed in the trigger
|
||||||
if (!$varInAfterRouting && !empty($fieldsTrigger)) {
|
if (!$varInAfterRouting && !empty($fieldsTrigger)) {
|
||||||
$varInAfterRouting = true;
|
$varInAfterRouting = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Merge the appData with variables changed
|
|
||||||
$fieldsCase = array_merge($fieldsCase, $fieldsTrigger);
|
|
||||||
} else {
|
} else {
|
||||||
$fieldsCase = $appDataAfterTrigger;
|
$fieldsCase = $appDataAfterTrigger;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -401,27 +401,27 @@ function verifyCsrfToken($request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the difference between to multidimensional array
|
* Get the difference between to arrays
|
||||||
|
* If the element is an array we will to keep the value from $array1
|
||||||
|
* If the element is an object we will to keep the value from $array1
|
||||||
*
|
*
|
||||||
* @param array $array1
|
* @param array $array1
|
||||||
* @param array $array2
|
* @param array $array2
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function arrayDiffRecursive(array $array1, array $array2)
|
function getDiffBetweenModifiedVariables(array $array1, array $array2)
|
||||||
{
|
{
|
||||||
$difference = [];
|
$difference = [];
|
||||||
foreach ($array1 as $key => $value) {
|
foreach ($array1 as $key => $value) {
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
if (!isset($array2[$key])) {
|
if ($value !== $array2[$key]) {
|
||||||
$difference[$key] = $value;
|
$difference[$key] = $value;
|
||||||
} elseif (!is_array($array2[$key])) {
|
}
|
||||||
|
} elseif (is_object($value)) {
|
||||||
|
// When using ===, it means object variables are identical and they refer to the same instance of the same class.
|
||||||
|
if ($value != $array2[$key]) {
|
||||||
$difference[$key] = $value;
|
$difference[$key] = $value;
|
||||||
} else {
|
|
||||||
$new_diff = arrayDiffRecursive($value, $array2[$key]);
|
|
||||||
if (!empty($new_diff)) {
|
|
||||||
$difference[$key] = $new_diff;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} elseif (!isset($array2[$key]) || $array2[$key] != $value) {
|
} elseif (!isset($array2[$key]) || $array2[$key] != $value) {
|
||||||
$difference[$key] = $value;
|
$difference[$key] = $value;
|
||||||
|
|||||||
Reference in New Issue
Block a user