mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 14:03:27 +00:00
Fix doctrine transaction in lazaret patch
This commit is contained in:
@@ -81,10 +81,8 @@ class patch_370a7 implements patchInterface
|
|||||||
$this->truncateTable($app['EM'], 'Entities\\LazaretFile');
|
$this->truncateTable($app['EM'], 'Entities\\LazaretFile');
|
||||||
$this->truncateTable($app['EM'], 'Entities\\LazaretSession');
|
$this->truncateTable($app['EM'], 'Entities\\LazaretSession');
|
||||||
|
|
||||||
// suspend auto-commit
|
$i = 0;
|
||||||
$app['EM']->getConnection()->beginTransaction();
|
|
||||||
|
|
||||||
try {
|
|
||||||
foreach ($rs as $row) {
|
foreach ($rs as $row) {
|
||||||
|
|
||||||
$filePath = $app['root.path'] . '/tmp/lazaret/' . $row['filepath'];
|
$filePath = $app['root.path'] . '/tmp/lazaret/' . $row['filepath'];
|
||||||
@@ -137,14 +135,16 @@ class patch_370a7 implements patchInterface
|
|||||||
$lazaretFile->setSession($lazaretSession);
|
$lazaretFile->setSession($lazaretSession);
|
||||||
|
|
||||||
$app['EM']->persist($lazaretFile);
|
$app['EM']->persist($lazaretFile);
|
||||||
|
|
||||||
|
if (0 === ++$i % 100) {
|
||||||
|
$app['EM']->flush();
|
||||||
|
$app['EM']->clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$app['EM']->flush();
|
$app['EM']->flush();
|
||||||
} catch (\Exception $e) {
|
$app['EM']->clear();
|
||||||
$app['EM']->getConnection()->rollback();
|
|
||||||
$app['EM']->close();
|
|
||||||
}
|
|
||||||
|
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user