]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/emailsettings.php
Managed_DataObject->updateWithKeys throws its own exception
[quix0rs-gnu-social.git] / actions / emailsettings.php
index 483131c779f9d415f55311b8d0723ccfbfab2f82..0c2033d821d0587a0bcbf5aeb974d17ad3024ebd 100644 (file)
@@ -478,20 +478,12 @@ class EmailsettingsAction extends SettingsAction
             return;
         }
 
-        $user->query('BEGIN');
-
         $original = clone($user);
 
         $user->email = null;
 
-        $result = $user->updateWithKeys($original);
-
-        if (!$result) {
-            common_log_db_error($user, 'UPDATE', __FILE__);
-            // TRANS: Server error thrown on database error removing a registered e-mail address.
-            $this->serverError(_('Could not update user.'));
-        }
-        $user->query('COMMIT');
+        // Throws exception on failure. Also performs it within a transaction.
+        $user->updateWithKeys($original);
 
         // TRANS: Message given after successfully removing a registered e-mail address.
         $this->showForm(_('The email address was removed.'), true);
@@ -517,11 +509,8 @@ class EmailsettingsAction extends SettingsAction
         $user->incomingemail = null;
         $user->emailpost = 0;
 
-        if (!$user->updateWithKeys($orig)) {
-            common_log_db_error($user, 'UPDATE', __FILE__);
-            // TRANS: Server error thrown on database error removing incoming e-mail address.
-            $this->serverError(_('Could not update user record.'));
-        }
+        // Throws exception on failure. Also performs it within a transaction.
+        $user->updateWithKeys($orig);
 
         // TRANS: Message given after successfully removing an incoming e-mail address.
         $this->showForm(_('Incoming email address removed.'), true);
@@ -541,11 +530,8 @@ class EmailsettingsAction extends SettingsAction
         $user->incomingemail = mail_new_incoming_address();
         $user->emailpost = 1;
 
-        if (!$user->updateWithKeys($orig)) {
-            common_log_db_error($user, 'UPDATE', __FILE__);
-            // TRANS: Server error thrown on database error adding incoming e-mail address.
-            $this->serverError(_('Could not update user record.'));
-        }
+        // Throws exception on failure. Also performs it within a transaction.
+        $user->updateWithKeys($orig);
 
         // TRANS: Message given after successfully adding an incoming e-mail address.
         $this->showForm(_('New incoming email address added.'), true);