diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index a1370029a..78b0f6acd 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -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. */ diff --git a/src/Appwrite/Migration/Version/V07.php b/src/Appwrite/Migration/Version/V07.php index 7cd3b8fef..9c3054a28 100644 --- a/src/Appwrite/Migration/Version/V07.php +++ b/src/Appwrite/Migration/Version/V07.php @@ -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.