From 4ae78cd172c9efcaa8199d9366bfe2103bcc71c1 Mon Sep 17 00:00:00 2001 From: Nuno Tavares Date: Mon, 22 Apr 2024 09:35:55 +0200 Subject: [PATCH] dont assume 'quota' will be in the values, just like block before wasn't assuming (#823) Co-authored-by: Nuno Tavares --- model/MailboxHandler.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/model/MailboxHandler.php b/model/MailboxHandler.php index 38d1c594..b78cb339 100644 --- a/model/MailboxHandler.php +++ b/model/MailboxHandler.php @@ -239,17 +239,17 @@ protected function read_from_db_postprocess($db_result) protected function preSave(): bool { - if (isset($this->values['quota']) && $this->values['quota'] != -1 && is_numeric($this->values['quota'])) { - $multiplier = Config::read_string('quota_multiplier'); - if ($multiplier == 0 || !is_numeric($multiplier)) { // or empty string, or null, or false... - $multiplier = 1; + if (isset($this->values['quota'])) { + if ($this->values['quota'] != -1 && is_numeric($this->values['quota'])) { + $multiplier = Config::read_string('quota_multiplier'); + if ($multiplier == 0 || !is_numeric($multiplier)) { // or empty string, or null, or false... + $multiplier = 1; + } + $this->values['quota'] = $this->values['quota'] * $multiplier; # convert quota from MB to bytes + // Avoid trying to store '' in an integer field + if ($this->values['quota'] === '') { + $this->values['quota'] = 0; } - $this->values['quota'] = $this->values['quota'] * $multiplier; # convert quota from MB to bytes - } - - // Avoid trying to store '' in an integer field - if ($this->values['quota'] === '') { - $this->values['quota'] = 0; } $ah = new AliasHandler($this->new, $this->admin_username);