Loading composer.lock +4 −3 Original line number Diff line number Diff line Loading @@ -11450,7 +11450,7 @@ "source": { "type": "git", "url": "https://git.unicaen.fr/lib/unicaen/db-import.git", "reference": "bff6eb4a61e9f2fc518c0083231b25bc1f189829" "reference": "feca088fc7fccb2d9649ff35abcb509586a79da6" }, "require": { "beberlei/assert": "^3.3", Loading @@ -11462,7 +11462,8 @@ "php": "^8.0", "ramsey/uuid": "^3.0", "unicaen/app": "^6.0", "unicaen/livelog": "^2.0" "unicaen/livelog": "^2.0", "webmozart/assert": "^1.3" }, "require-dev": { "phpunit/phpunit": "^8.0" Loading @@ -11482,7 +11483,7 @@ } }, "description": "Module d'import entre bases de données", "time": "2023-06-05T11:55:09+00:00" "time": "2023-06-09T09:50:43+00:00" }, { "name": "unicaen/faq", Loading docker/configs/php/fpm/conf.d/99-sygal.ini +2 −2 Original line number Diff line number Diff line Loading @@ -18,13 +18,13 @@ post_max_size = 502M ######## opcache ######### opcache.enable=1 opcache.enable=0 opcache.memory_consumption=128 opcache.interned_strings_buffer=8 opcache.max_accelerated_files=4000 opcache.revalidate_freq=60 opcache.fast_shutdown=1 opcache.enable_cli=1 opcache.enable_cli=0 ######## memcached ######### Loading module/Import/src/Import/Service/SynchroService.php +2 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,8 @@ class SynchroService /** * Lance la synchro des données par UnicaenImport pour tous les services inscrits. * * @throws \Doctrine\DBAL\Exception Erreur imprévue en base de données */ public function synchronize() { Loading module/SygalApiImpl/src/V1/Exception/ErrorDuringImportException.php 0 → 100644 +10 −0 Original line number Diff line number Diff line <?php namespace SygalApiImpl\V1\Exception; use Exception; class ErrorDuringImportException extends Exception { } No newline at end of file module/SygalApiImpl/src/V1/Facade/AbstractImportFacade.php +45 −9 Original line number Diff line number Diff line Loading @@ -3,9 +3,14 @@ namespace SygalApiImpl\V1\Facade; use Doctrine\DBAL\Connection; use Exception; use RuntimeException; use stdClass; use UnicaenDbImport\Domain\Import; use UnicaenDbImport\Domain\ImportResult; use UnicaenDbImport\Domain\Synchro; use UnicaenDbImport\Domain\SynchroResult; use UnicaenDbImport\Service\Exception\DatabaseServiceException; use UnicaenDbImport\Service\ImportService; use UnicaenDbImport\Service\SynchroService; Loading Loading @@ -38,24 +43,55 @@ abstract class AbstractImportFacade /** * @throws \Exception */ protected function runImport(Import $import) protected function runImport(Import $import): ImportResult { $result = $this->importService->runImport($import); if ($exception = $result->getFailureException()) { throw $exception; try { return $this->importService->runImport($import); } catch (DatabaseServiceException $e) { throw new Exception("Une erreur est survenue lors de l'import : " . $e->getMessage(), null, $e); } } /** * @throws \Exception */ protected function runSynchro(Synchro $import) protected function runSynchro(Synchro $synchro): SynchroResult { try { return $this->synchroService->runSynchro($synchro); } catch (DatabaseServiceException $e) { throw new Exception("Une erreur est survenue lors de la synchro : " . $e->getMessage(), null, $e); } } protected function beginTransaction(): void { try { $this->destinationConnection->setNestTransactionsWithSavepoints(true); // transactions imbriquées $this->destinationConnection->beginTransaction(); } catch (\Doctrine\DBAL\Exception $e) { throw new RuntimeException("Echec de l'ouverture d'une transaction en bdd", null, $e); } } protected function commit() { $result = $this->synchroService->runSynchro($import); try { $this->destinationConnection->commit(); } catch (\Doctrine\DBAL\Exception $e) { $exception = new RuntimeException("Echec du commit en bdd, rollback.", null, $e); $this->rollback($exception); } } if ($exception = $result->getFailureException()) { throw $exception; protected function rollback(Exception $reason) { try { $this->destinationConnection->rollback(); } catch (\Doctrine\DBAL\Exception $e) { throw new RuntimeException( sprintf("Echec du rollback en bdd (raison du rollback : %s)", $reason->getMessage()), null, $e ); } } } No newline at end of file Loading
composer.lock +4 −3 Original line number Diff line number Diff line Loading @@ -11450,7 +11450,7 @@ "source": { "type": "git", "url": "https://git.unicaen.fr/lib/unicaen/db-import.git", "reference": "bff6eb4a61e9f2fc518c0083231b25bc1f189829" "reference": "feca088fc7fccb2d9649ff35abcb509586a79da6" }, "require": { "beberlei/assert": "^3.3", Loading @@ -11462,7 +11462,8 @@ "php": "^8.0", "ramsey/uuid": "^3.0", "unicaen/app": "^6.0", "unicaen/livelog": "^2.0" "unicaen/livelog": "^2.0", "webmozart/assert": "^1.3" }, "require-dev": { "phpunit/phpunit": "^8.0" Loading @@ -11482,7 +11483,7 @@ } }, "description": "Module d'import entre bases de données", "time": "2023-06-05T11:55:09+00:00" "time": "2023-06-09T09:50:43+00:00" }, { "name": "unicaen/faq", Loading
docker/configs/php/fpm/conf.d/99-sygal.ini +2 −2 Original line number Diff line number Diff line Loading @@ -18,13 +18,13 @@ post_max_size = 502M ######## opcache ######### opcache.enable=1 opcache.enable=0 opcache.memory_consumption=128 opcache.interned_strings_buffer=8 opcache.max_accelerated_files=4000 opcache.revalidate_freq=60 opcache.fast_shutdown=1 opcache.enable_cli=1 opcache.enable_cli=0 ######## memcached ######### Loading
module/Import/src/Import/Service/SynchroService.php +2 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,8 @@ class SynchroService /** * Lance la synchro des données par UnicaenImport pour tous les services inscrits. * * @throws \Doctrine\DBAL\Exception Erreur imprévue en base de données */ public function synchronize() { Loading
module/SygalApiImpl/src/V1/Exception/ErrorDuringImportException.php 0 → 100644 +10 −0 Original line number Diff line number Diff line <?php namespace SygalApiImpl\V1\Exception; use Exception; class ErrorDuringImportException extends Exception { } No newline at end of file
module/SygalApiImpl/src/V1/Facade/AbstractImportFacade.php +45 −9 Original line number Diff line number Diff line Loading @@ -3,9 +3,14 @@ namespace SygalApiImpl\V1\Facade; use Doctrine\DBAL\Connection; use Exception; use RuntimeException; use stdClass; use UnicaenDbImport\Domain\Import; use UnicaenDbImport\Domain\ImportResult; use UnicaenDbImport\Domain\Synchro; use UnicaenDbImport\Domain\SynchroResult; use UnicaenDbImport\Service\Exception\DatabaseServiceException; use UnicaenDbImport\Service\ImportService; use UnicaenDbImport\Service\SynchroService; Loading Loading @@ -38,24 +43,55 @@ abstract class AbstractImportFacade /** * @throws \Exception */ protected function runImport(Import $import) protected function runImport(Import $import): ImportResult { $result = $this->importService->runImport($import); if ($exception = $result->getFailureException()) { throw $exception; try { return $this->importService->runImport($import); } catch (DatabaseServiceException $e) { throw new Exception("Une erreur est survenue lors de l'import : " . $e->getMessage(), null, $e); } } /** * @throws \Exception */ protected function runSynchro(Synchro $import) protected function runSynchro(Synchro $synchro): SynchroResult { try { return $this->synchroService->runSynchro($synchro); } catch (DatabaseServiceException $e) { throw new Exception("Une erreur est survenue lors de la synchro : " . $e->getMessage(), null, $e); } } protected function beginTransaction(): void { try { $this->destinationConnection->setNestTransactionsWithSavepoints(true); // transactions imbriquées $this->destinationConnection->beginTransaction(); } catch (\Doctrine\DBAL\Exception $e) { throw new RuntimeException("Echec de l'ouverture d'une transaction en bdd", null, $e); } } protected function commit() { $result = $this->synchroService->runSynchro($import); try { $this->destinationConnection->commit(); } catch (\Doctrine\DBAL\Exception $e) { $exception = new RuntimeException("Echec du commit en bdd, rollback.", null, $e); $this->rollback($exception); } } if ($exception = $result->getFailureException()) { throw $exception; protected function rollback(Exception $reason) { try { $this->destinationConnection->rollback(); } catch (\Doctrine\DBAL\Exception $e) { throw new RuntimeException( sprintf("Echec du rollback en bdd (raison du rollback : %s)", $reason->getMessage()), null, $e ); } } } No newline at end of file