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:
Paula Quispe
2019-05-02 19:11:00 +00:00
committed by Julio Cesar Laura Avendaño
2 changed files with 15 additions and 15 deletions

View File

@@ -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 $array2
*
* @return array
*/
function arrayDiffRecursive(array $array1, array $array2)
*/
function getDiffBetweenModifiedVariables(array $array1, array $array2)
{
$difference = [];
foreach ($array1 as $key => $value) {
if (is_array($value)) {
if (!isset($array2[$key])) {
if ($value !== $array2[$key]) {
$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;
} else {
$new_diff = arrayDiffRecursive($value, $array2[$key]);
if (!empty($new_diff)) {
$difference[$key] = $new_diff;
}
}
} elseif (!isset($array2[$key]) || $array2[$key] != $value) {
$difference[$key] = $value;