Fix doctrine transaction in lazaret patch

This commit is contained in:
Romain Neutron
2013-10-28 23:20:42 +01:00
parent 9d69c8dc3f
commit ebe4f00c6b

View File

@@ -81,10 +81,8 @@ class patch_370a7 implements patchInterface
$this->truncateTable($app['EM'], 'Entities\\LazaretFile');
$this->truncateTable($app['EM'], 'Entities\\LazaretSession');
// suspend auto-commit
$app['EM']->getConnection()->beginTransaction();
$i = 0;
try {
foreach ($rs as $row) {
$filePath = $app['root.path'] . '/tmp/lazaret/' . $row['filepath'];
@@ -137,14 +135,16 @@ class patch_370a7 implements patchInterface
$lazaretFile->setSession($lazaretSession);
$app['EM']->persist($lazaretFile);
if (0 === ++$i % 100) {
$app['EM']->flush();
$app['EM']->clear();
}
}
}
$app['EM']->flush();
} catch (\Exception $e) {
$app['EM']->getConnection()->rollback();
$app['EM']->close();
}
$app['EM']->clear();
$stmt->closeCursor();