1
0
Fork 0
mirror of synced 2024-06-20 03:30:30 +12:00

fix: comparing multidimensional array on migration

This commit is contained in:
Torsten Dittmann 2021-04-16 09:08:42 +02:00
parent f6aa9e8108
commit 52574d40dd
2 changed files with 29 additions and 3 deletions

View file

@ -89,8 +89,8 @@ abstract class Migration
if (empty($new->getId())) {
throw new Exception('Missing ID');
}
if (!array_diff_assoc($new->getArrayCopy(), $old)) {
if (!$this->check_diff_multi($new->getArrayCopy(), $old)) {
return;
}
@ -112,6 +112,33 @@ abstract class Migration
}
}
public function check_diff_multi($array1, $array2){
$result = array();
foreach($array1 as $key => $val) {
if(is_array($val) && isset($array2[$key])) {
$tmp = $this->check_diff_multi($val, $array2[$key]);
if($tmp) {
$result[$key] = $tmp;
}
}
elseif(!isset($array2[$key])) {
$result[$key] = null;
}
elseif($val !== $array2[$key]) {
$result[$key] = $array2[$key];
}
if(isset($array2[$key])) {
unset($array2[$key]);
}
}
$result = array_merge($result, $array2);
return $result;
}
/**
* Executes migration for set project.
*/

View file

@ -38,7 +38,6 @@ class V07 extends Migration
$document->removeAttribute('oauth2' . \ucfirst($key) . 'AccessToken');
}
}
/**
* Invalidate all Login Tokens, since they can't be migrated to the new structure.
* Reason for it is the missing distinction between E-Mail and OAuth2 tokens.