diff options
author | Joas Schilling <coding@schilljs.com> | 2020-12-03 12:16:39 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-12-07 14:19:38 +0100 |
commit | f648635758e34bab0173e02eb9b75aafc5e6a9ff (patch) | |
tree | 2864de1966f655eeef2078d14b5837821869c17f /lib | |
parent | f0ca76aefbe7717b9555e0dffb8c9340e14bf3cf (diff) | |
download | nextcloud-server-f648635758e34bab0173e02eb9b75aafc5e6a9ff.tar.gz nextcloud-server-f648635758e34bab0173e02eb9b75aafc5e6a9ff.zip |
Make the throwing optional, so background tasks don't break
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Accounts/AccountManager.php | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php index 8640ce269ea..05feaf87b8f 100644 --- a/lib/private/Accounts/AccountManager.php +++ b/lib/private/Accounts/AccountManager.php @@ -125,15 +125,23 @@ class AccountManager implements IAccountManager { * * @param IUser $user * @param array $data + * @param bool $throwOnData Set to true if you can inform the user about invalid data * @return array The potentially modified data (e.g. phone numbers are converted to E.164 format) * @throws \InvalidArgumentException Message is the property that was invalid */ - public function updateUser(IUser $user, array $data): array { + public function updateUser(IUser $user, array $data, bool $throwOnData = false): array { $userData = $this->getUser($user); $updated = true; - if (isset($data[self::PROPERTY_PHONE])) { - $data[self::PROPERTY_PHONE]['value'] = $this->parsePhoneNumber($data[self::PROPERTY_PHONE]['value']); + if (isset($data[self::PROPERTY_PHONE]) && $data[self::PROPERTY_PHONE]['value'] !== '') { + try { + $data[self::PROPERTY_PHONE]['value'] = $this->parsePhoneNumber($data[self::PROPERTY_PHONE]['value']); + } catch (\InvalidArgumentException $e) { + if ($throwOnData) { + throw $e; + } + $data[self::PROPERTY_PHONE]['value'] = ''; + } } if (empty($userData)) { |