Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
fix(upgrade): check sql transaction before commit and rollback (#10250)
Browse files Browse the repository at this point in the history
Refs: MON-10926
  • Loading branch information
kduret committed Nov 4, 2021
1 parent ab5aead commit 40ef8db
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
9 changes: 7 additions & 2 deletions www/install/php/Update-21.04.1.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,14 @@
$statement->bindValue(':criterias', $criterias, \PDO::PARAM_STR);
$statement->execute();
}
$pearDB->commit();

if ($pearDB->inTransaction()) {
$pearDB->commit();
}
} catch (\Exception $e) {
$pearDB->rollBack();
if ($pearDB->inTransaction()) {
$pearDB->rollBack();
}
$centreonLog->insertLog(
4,
$versionOfTheUpgrade . $errorMessage .
Expand Down
9 changes: 7 additions & 2 deletions www/install/php/Update-21.04.2.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@
$statement->bindValue(':moduleMetaId', (int) $moduleMetaId, \PDO::PARAM_INT);
$statement->execute();
}
$pearDB->commit();

if ($pearDB->inTransaction()) {
$pearDB->commit();
}
} catch (\Exception $e) {
$pearDB->rollBack();
if ($pearDB->inTransaction()) {
$pearDB->rollBack();
}
$centreonLog->insertLog(
4,
$versionOfTheUpgrade . $errorMessage .
Expand Down
9 changes: 7 additions & 2 deletions www/install/php/Update-21.04.5.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@
"ALTER TABLE `contact` ADD COLUMN `contact_platform_data_sending` ENUM('0', '1', '2')"
);
}
$pearDB->commit();

if ($pearDB->inTransaction()) {
$pearDB->commit();
}
} catch (\Exception $e) {
$pearDB->rollBack();
if ($pearDB->inTransaction()) {
$pearDB->rollBack();
}
$centreonLog->insertLog(
4,
$versionOfTheUpgrade . $errorMessage .
Expand Down

0 comments on commit 40ef8db

Please sign in to comment.