mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 00:12:30 -05:00
Wrap mimetype insert and getLastInsertId in a transaction
Signed-off-by: Lucas Azevedo <lhs_azevedo@hotmail.com>
This commit is contained in:
parent
5de021cb9a
commit
c587f684bd
1 changed files with 9 additions and 7 deletions
|
|
@ -117,13 +117,15 @@ class Loader implements IMimeTypeLoader {
|
|||
*/
|
||||
protected function store($mimetype) {
|
||||
try {
|
||||
$insert = $this->dbConnection->getQueryBuilder();
|
||||
$insert->insert('mimetypes')
|
||||
->values([
|
||||
'mimetype' => $insert->createNamedParameter($mimetype)
|
||||
])
|
||||
->executeStatement();
|
||||
$mimetypeId = $insert->getLastInsertId();
|
||||
$mimetypeId = $this->atomic(function () use ($mimetype) {
|
||||
$insert = $this->dbConnection->getQueryBuilder();
|
||||
$insert->insert('mimetypes')
|
||||
->values([
|
||||
'mimetype' => $insert->createNamedParameter($mimetype)
|
||||
])
|
||||
->executeStatement();
|
||||
return $insert->getLastInsertId();
|
||||
}, $this->dbConnection);
|
||||
} catch (DbalException $e) {
|
||||
if ($e->getReason() !== DBException::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
|
||||
throw $e;
|
||||
|
|
|
|||
Loading…
Reference in a new issue