remove unnecessary startTransaction and commit calls

This commit is contained in:
bence committed 2023-04-20 00:39:10 +02:00
1 parent 8141845ae9
commit ee4a9f2ce3
3 files changed
-32

No files matched your search

-20
View File
@@ -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();
-8
View File
@@ -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]);
}
-4
View File
@@ -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]);