From 0546e200119069164456723478da579efdae58c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Thu, 20 Apr 2023 00:07:25 +0200 Subject: [PATCH] remove unnecessary startTransaction and commit calls --- src/Controller/LoginController.php | 20 -------------------- src/Controller/MapAdminController.php | 8 -------- src/Controller/UserController.php | 4 ---- 3 files changed, 32 deletions(-) diff --git a/src/Controller/LoginController.php b/src/Controller/LoginController.php index 7705413..fa0961b 100644 --- a/src/Controller/LoginController.php +++ b/src/Controller/LoginController.php @@ -346,8 +346,6 @@ class LoginController $user->setPlainPassword($this->request->post('password')); $user->setCreatedDate(new DateTime()); - \Container::$dbConnection->startTransaction(); - $this->pdm->saveToDb($user); $token = bin2hex(random_bytes(16)); @@ -359,8 +357,6 @@ class LoginController $this->pdm->saveToDb($confirmation); - \Container::$dbConnection->commit(); - $this->sendConfirmationEmail($user->getEmail(), $token, $user->getCreatedDate()); $this->request->session()->delete('tmp_user_data'); @@ -432,8 +428,6 @@ class LoginController return new HtmlContent('login/activate'); } - \Container::$dbConnection->startTransaction(); - $this->pdm->deleteFromDb($confirmation); $user = $this->userRepository->getById($confirmation->getUserId()); @@ -441,8 +435,6 @@ class LoginController $this->pdm->saveToDb($user); - \Container::$dbConnection->commit(); - $this->request->setUser($user); $this->deleteRedirectUrl(); @@ -462,8 +454,6 @@ class LoginController return new HtmlContent('login/cancel', ['success' => false]); } - \Container::$dbConnection->startTransaction(); - $this->pdm->deleteFromDb($confirmation); $user = $this->userRepository->getById($confirmation->getUserId()); @@ -474,8 +464,6 @@ class LoginController $this->pdm->deleteFromDb($user); - \Container::$dbConnection->commit(); - return new HtmlContent('login/cancel', ['success' => true]); } @@ -541,16 +529,12 @@ class LoginController $passwordResetter->setToken($token); $passwordResetter->setExpiresDate($expires); - \Container::$dbConnection->startTransaction(); - if ($existingResetter !== null) { $this->pdm->deleteFromDb($existingResetter); } $this->pdm->saveToDb($passwordResetter); - \Container::$dbConnection->commit(); - $this->sendPasswordResetEmail($user->getEmail(), $token, $expires); return new JsonContent(['success' => true]); @@ -591,8 +575,6 @@ class LoginController return new JsonContent(['error' => ['errorText' => 'The given passwords do not match.']]); } - \Container::$dbConnection->startTransaction(); - $this->pdm->deleteFromDb($resetter); $user = $this->userRepository->getById($resetter->getUserId()); @@ -600,8 +582,6 @@ class LoginController $this->pdm->saveToDb($user); - \Container::$dbConnection->commit(); - $this->request->setUser($user); $this->deleteRedirectUrl(); diff --git a/src/Controller/MapAdminController.php b/src/Controller/MapAdminController.php index 47a972f..8d89a1d 100644 --- a/src/Controller/MapAdminController.php +++ b/src/Controller/MapAdminController.php @@ -104,8 +104,6 @@ class MapAdminController implements IAuthenticationRequired, ISecured { $mapId = (int) $this->request->query('mapId'); - \Container::$dbConnection->startTransaction(); - if ($mapId) { $map = $this->mapRepository->getById($mapId); } else { @@ -186,8 +184,6 @@ class MapAdminController implements IAuthenticationRequired, ISecured $this->pdm->saveToDb($map); - \Container::$dbConnection->commit(); - return new JsonContent(['mapId' => $map->getId(), 'added' => $addedIds]); } @@ -197,14 +193,10 @@ class MapAdminController implements IAuthenticationRequired, ISecured $map = $this->mapRepository->getById($mapId); - \Container::$dbConnection->startTransaction(); - $this->deletePlaces($map); $this->pdm->deleteFromDb($map); - \Container::$dbConnection->commit(); - return new JsonContent(['success' => true]); } diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 0fcb69f..305b51b 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -199,8 +199,6 @@ class UserController implements IAuthenticationRequired return new JsonContent(['error' => ['errorText' => $error]]); } - \Container::$dbConnection->startTransaction(); - $userConfirmation = $this->userConfirmationRepository->getByUser($user); if ($userConfirmation !== null) { $this->pdm->deleteFromDb($userConfirmation); @@ -225,8 +223,6 @@ class UserController implements IAuthenticationRequired $this->pdm->deleteFromDb($user); - \Container::$dbConnection->commit(); - $this->request->session()->delete('authenticated_with_google_until'); return new JsonContent(['success' => true]);