From 4fab4465cc5ccc0c3c9efe973afedb9a79b364ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milan=20Dav=C3=ADdek?= Date: Sun, 11 Oct 2020 10:58:05 +0200 Subject: [PATCH 1/5] Make overrides of Mage_Core_Model_Resource_Db_Abstract::delete to respect parent api --- app/code/core/Mage/Admin/Model/Resource/User.php | 11 +++++------ app/code/core/Mage/Api/Model/Resource/User.php | 10 ++++------ .../core/Mage/Core/Model/Resource/Db/Abstract.php | 1 + 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app/code/core/Mage/Admin/Model/Resource/User.php b/app/code/core/Mage/Admin/Model/Resource/User.php index 536c3ac9497..75cdb9af6b3 100644 --- a/app/code/core/Mage/Admin/Model/Resource/User.php +++ b/app/code/core/Mage/Admin/Model/Resource/User.php @@ -195,7 +195,8 @@ protected function _afterLoad(Mage_Core_Model_Abstract $user) * Delete user role record with user * * @param Mage_Core_Model_Abstract $user - * @return bool + * @return $this + * @throws Exception */ public function delete(Mage_Core_Model_Abstract $user) { @@ -212,15 +213,13 @@ public function delete(Mage_Core_Model_Abstract $user) $adapter->delete($this->getMainTable(), $conditions); $adapter->delete($this->getTable('admin/role'), $conditions); $adapter->commit(); - } catch (Mage_Core_Exception $e) { + } + catch (Exception $e) { $adapter->rollBack(); throw $e; - } catch (Exception $e) { - $adapter->rollBack(); - return false; } $this->_afterDelete($user); - return true; + return $this; } /** diff --git a/app/code/core/Mage/Api/Model/Resource/User.php b/app/code/core/Mage/Api/Model/Resource/User.php index 5bb73b84118..3015ec40e1b 100644 --- a/app/code/core/Mage/Api/Model/Resource/User.php +++ b/app/code/core/Mage/Api/Model/Resource/User.php @@ -236,7 +236,8 @@ protected function _beforeSave(Mage_Core_Model_Abstract $user) * Delete the object * * @param Mage_Core_Model_Abstract $user - * @return boolean + * @return $this + * @throws Exception */ public function delete(Mage_Core_Model_Abstract $user) { @@ -247,14 +248,11 @@ public function delete(Mage_Core_Model_Abstract $user) $dbh->delete($this->getTable('api/user'), array('user_id = ?' => $uid)); $dbh->delete($this->getTable('api/role'), array('user_id = ?' => $uid)); $dbh->commit(); - } catch (Mage_Core_Exception $e) { - $dbh->rollBack(); - throw $e; } catch (Exception $e) { $dbh->rollBack(); - return false; + throw $e; } - return true; + return $this; } /** diff --git a/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php b/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php index 7204451d9a8..351cc91b1c7 100644 --- a/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php +++ b/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php @@ -499,6 +499,7 @@ public function forsedSave(Mage_Core_Model_Abstract $object) * * @param Mage_Core_Model_Abstract $object * @return $this + * @throws Exception */ public function delete(Mage_Core_Model_Abstract $object) { From c1f93343cce14cf078c9bfffb4cf2a763b026a64 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Wed, 15 Jun 2022 19:56:17 +0100 Subject: [PATCH 2/5] switch Exception to Throwable --- app/code/core/Mage/Admin/Model/Resource/User.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/code/core/Mage/Admin/Model/Resource/User.php b/app/code/core/Mage/Admin/Model/Resource/User.php index 75cdb9af6b3..96f660e80bd 100644 --- a/app/code/core/Mage/Admin/Model/Resource/User.php +++ b/app/code/core/Mage/Admin/Model/Resource/User.php @@ -196,7 +196,7 @@ protected function _afterLoad(Mage_Core_Model_Abstract $user) * * @param Mage_Core_Model_Abstract $user * @return $this - * @throws Exception + * @throws Throwable */ public function delete(Mage_Core_Model_Abstract $user) { @@ -213,8 +213,7 @@ public function delete(Mage_Core_Model_Abstract $user) $adapter->delete($this->getMainTable(), $conditions); $adapter->delete($this->getTable('admin/role'), $conditions); $adapter->commit(); - } - catch (Exception $e) { + } catch (Throwable $e) { $adapter->rollBack(); throw $e; } From 70c951b4d11e34d62b7bc7a53782a48b13b2df1b Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Wed, 15 Jun 2022 19:57:25 +0100 Subject: [PATCH 3/5] Switched Exception to Throwable --- app/code/core/Mage/Api/Model/Resource/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/core/Mage/Api/Model/Resource/User.php b/app/code/core/Mage/Api/Model/Resource/User.php index 3015ec40e1b..08c309a845a 100644 --- a/app/code/core/Mage/Api/Model/Resource/User.php +++ b/app/code/core/Mage/Api/Model/Resource/User.php @@ -248,7 +248,7 @@ public function delete(Mage_Core_Model_Abstract $user) $dbh->delete($this->getTable('api/user'), array('user_id = ?' => $uid)); $dbh->delete($this->getTable('api/role'), array('user_id = ?' => $uid)); $dbh->commit(); - } catch (Exception $e) { + } catch (Throwable $e) { $dbh->rollBack(); throw $e; } From b0cd39de57b35fbaeddf611f8b456a25bac77b84 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Wed, 15 Jun 2022 19:57:53 +0100 Subject: [PATCH 4/5] typo --- app/code/core/Mage/Admin/Model/Resource/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/core/Mage/Admin/Model/Resource/User.php b/app/code/core/Mage/Admin/Model/Resource/User.php index 96f660e80bd..057b8d63653 100644 --- a/app/code/core/Mage/Admin/Model/Resource/User.php +++ b/app/code/core/Mage/Admin/Model/Resource/User.php @@ -196,7 +196,7 @@ protected function _afterLoad(Mage_Core_Model_Abstract $user) * * @param Mage_Core_Model_Abstract $user * @return $this - * @throws Throwable + * @throws Exception */ public function delete(Mage_Core_Model_Abstract $user) { From 64808b0de5a0c1c158a078318f69d2a2c0e67914 Mon Sep 17 00:00:00 2001 From: Mohamed ELIDRISSI <67818913+elidrissidev@users.noreply.github.com> Date: Tue, 11 Oct 2022 10:45:02 +0100 Subject: [PATCH 5/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index de376cea193..2926afbc08c 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,7 @@ Do not use 20.x.x if you need IE support. - removed module `Mage_PageCache` [#2258](https://github.com/OpenMage/magento-lts/pull/2258) - removed lib/flex containing unused ActionScript "file uploader" files [#2271](https://github.com/OpenMage/magento-lts/pull/2271) - enabled website level config cache [#2355](https://github.com/OpenMage/magento-lts/pull/2355) +- make overrides of Mage_Core_Model_Resource_Db_Abstract::delete respect parent api [#1257](https://github.com/OpenMage/magento-lts/pull/1257) For full list of changes, you can [compare tags](https://github.com/OpenMage/magento-lts/compare/1.9.4.x...20.0).