diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php index cc65ae8caa18af7b2553218bc9a983ca6faa6a6c..3f4b1d9d79a8ba1762b28f48289e4f24bf7942ee 100644 --- a/lib/private/Accounts/AccountManager.php +++ b/lib/private/Accounts/AccountManager.php @@ -134,7 +134,11 @@ class AccountManager { return $userData; } - return json_decode($result[0]['data'], true); + $userDataArray = json_decode($result[0]['data'], true); + + $userDataArray = $this->addMissingDefaultValues($userDataArray); + + return $userDataArray; } /** @@ -159,6 +163,23 @@ class AccountManager { } } + /** + * make sure that all expected data are set + * + * @param array $userData + * @return array + */ + protected function addMissingDefaultValues(array $userData) { + + foreach ($userData as $key => $value) { + if (!isset($userData[$key]['verified'])) { + $userData[$key]['verified'] = self::NOT_VERIFIED; + } + } + + return $userData; + } + /** * reset verification status if personal data changed * @@ -190,19 +211,19 @@ class AccountManager { if($twitterVerified && $oldData[self::PROPERTY_TWITTER]['value'] !== $newData[self::PROPERTY_TWITTER]['value'] ) { - $newData[self::PROPERTY_TWITTER]['value']['verified'] = self::NOT_VERIFIED; + $newData[self::PROPERTY_TWITTER]['verified'] = self::NOT_VERIFIED; } if($websiteVerified && $oldData[self::PROPERTY_WEBSITE]['value'] !== $newData[self::PROPERTY_WEBSITE]['value'] ) { - $newData[self::PROPERTY_WEBSITE]['value']['verified'] = self::NOT_VERIFIED; + $newData[self::PROPERTY_WEBSITE]['verified'] = self::NOT_VERIFIED; } if($emailVerified && $oldData[self::PROPERTY_EMAIL]['value'] !== $newData[self::PROPERTY_EMAIL]['value'] ) { - $newData[self::PROPERTY_EMAIL]['value']['verified'] = self::NOT_VERIFIED; + $newData[self::PROPERTY_EMAIL]['verified'] = self::NOT_VERIFIED; } return $newData; @@ -263,19 +284,19 @@ class AccountManager { [ 'value' => '', 'scope' => self::VISIBILITY_PRIVATE, - 'verified' => '0', + 'verified' => self::NOT_VERIFIED, ], self::PROPERTY_WEBSITE => [ 'value' => '', 'scope' => self::VISIBILITY_PRIVATE, - 'verified' => '0', + 'verified' => self::NOT_VERIFIED, ], self::PROPERTY_EMAIL => [ 'value' => $user->getEMailAddress(), 'scope' => self::VISIBILITY_CONTACTS_ONLY, - 'verified' => '0', + 'verified' => self::NOT_VERIFIED, ], self::PROPERTY_AVATAR => [ @@ -285,13 +306,13 @@ class AccountManager { [ 'value' => '', 'scope' => self::VISIBILITY_PRIVATE, - 'verified' => '0', + 'verified' => self::NOT_VERIFIED, ], self::PROPERTY_TWITTER => [ 'value' => '', 'scope' => self::VISIBILITY_PRIVATE, - 'verified' => '0', + 'verified' => self::NOT_VERIFIED, ], ]; }