Fix sharing creation insert and get
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
parent
3612a1097a
commit
0cef6fd4e1
|
@ -204,32 +204,24 @@ class DefaultShareProvider implements IShareProvider {
|
||||||
$qb->setValue('file_target', $qb->createNamedParameter($share->getTarget()));
|
$qb->setValue('file_target', $qb->createNamedParameter($share->getTarget()));
|
||||||
|
|
||||||
// Set the time this share was created
|
// Set the time this share was created
|
||||||
$qb->setValue('stime', $qb->createNamedParameter(time()));
|
$time = time();
|
||||||
|
$qb->setValue('stime', $qb->createNamedParameter($time));
|
||||||
|
|
||||||
// insert the data and fetch the id of the share
|
// insert the data and fetch the id of the share
|
||||||
$this->dbConn->beginTransaction();
|
$qb->executeUpdate();
|
||||||
$qb->execute();
|
|
||||||
$id = $this->dbConn->lastInsertId('*PREFIX*share');
|
|
||||||
|
|
||||||
// Now fetch the inserted share and create a complete share object
|
// Update mandatory data
|
||||||
$qb = $this->dbConn->getQueryBuilder();
|
$id = $qb->getLastInsertId();
|
||||||
$qb->select('*')
|
$share->setId($id);
|
||||||
->from('share')
|
$share->setProviderId($this->identifier());
|
||||||
->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
|
|
||||||
|
|
||||||
$cursor = $qb->execute();
|
$shareTime = new \DateTime();
|
||||||
$data = $cursor->fetch();
|
$shareTime->setTimestamp($time);
|
||||||
$this->dbConn->commit();
|
$share->setShareTime($shareTime);
|
||||||
$cursor->closeCursor();
|
|
||||||
|
|
||||||
if ($data === false) {
|
|
||||||
throw new ShareNotFound('Newly created share could not be found');
|
|
||||||
}
|
|
||||||
|
|
||||||
$mailSendValue = $share->getMailSend();
|
$mailSendValue = $share->getMailSend();
|
||||||
$data['mail_send'] = ($mailSendValue === null) ? true : $mailSendValue;
|
$share->setMailSend(($mailSendValue === null) ? true : $mailSendValue);
|
||||||
|
|
||||||
$share = $this->createShare($data);
|
|
||||||
return $share;
|
return $share;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue