fix: comparing multidimensional array on migration
This commit is contained in:
parent
f6aa9e8108
commit
52574d40dd
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue