Skip to content

Commit

Permalink
Mage_Core_Model_Abstract: Fix rollback when Throwable is thrown in sa…
Browse files Browse the repository at this point in the history
…ve/delete method (#1483)

* Fix rollback when Throwable is thrown in save method

* Fixed typo, added Throwable support for delete method
  • Loading branch information
Sekiphp authored Apr 29, 2021
1 parent e83c915 commit 3c9fb54
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/code/core/Mage/Core/Model/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ protected function _hasModelChanged()
* Save object data
*
* @return $this
* @throws Throwable
*/
public function save()
{
Expand All @@ -334,7 +335,7 @@ public function save()
->commit();
$this->_hasDataChanges = false;
$dataCommited = true;
} catch (Exception $e) {
} catch (Throwable $e) {
$this->_getResource()->rollBack();
$this->_hasDataChanges = true;
throw $e;
Expand Down Expand Up @@ -483,6 +484,7 @@ protected function _afterSave()
* Delete object from database
*
* @return $this
* @throws Throwable
*/
public function delete()
{
Expand All @@ -493,7 +495,7 @@ public function delete()
$this->_afterDelete();

$this->_getResource()->commit();
} catch (Exception $e) {
} catch (Throwable $e) {
$this->_getResource()->rollBack();
throw $e;
}
Expand Down

0 comments on commit 3c9fb54

Please sign in to comment.