fix: comparing multidimensional array on migration
This commit is contained in:
parent
f6aa9e8108
commit
52574d40dd
2 changed files with 29 additions and 3 deletions
|
@ -90,7 +90,7 @@ abstract class Migration
|
||||||
throw new Exception('Missing ID');
|
throw new Exception('Missing ID');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!array_diff_assoc($new->getArrayCopy(), $old)) {
|
if (!$this->check_diff_multi($new->getArrayCopy(), $old)) {
|
||||||
return;
|
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.
|
* Executes migration for set project.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -38,7 +38,6 @@ class V07 extends Migration
|
||||||
$document->removeAttribute('oauth2' . \ucfirst($key) . 'AccessToken');
|
$document->removeAttribute('oauth2' . \ucfirst($key) . 'AccessToken');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidate all Login Tokens, since they can't be migrated to the new structure.
|
* 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.
|
* Reason for it is the missing distinction between E-Mail and OAuth2 tokens.
|
||||||
|
|
Loading…
Reference in a new issue