mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix(entity): Do not call getId when inserting and $id is null
Otherwise this breaks some existing code, in particular PublicKeyToken Signed-off-by: Carl Schwan <carlschwan@kde.org>
This commit is contained in:
parent
7c1a8a4060
commit
693a2263cc
2 changed files with 6 additions and 2 deletions
|
|
@ -102,7 +102,8 @@ class PublicKeyToken extends Entity implements INamedToken, IWipeableToken {
|
|||
}
|
||||
|
||||
public function getId(): int {
|
||||
return (int)$this->id;
|
||||
assert(!is_string($this->id) && $this->id !== null);
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getUID(): string {
|
||||
|
|
|
|||
|
|
@ -108,6 +108,9 @@ abstract class QBMapper {
|
|||
$getter = 'get' . ucfirst($property);
|
||||
$value = $entity->$getter();
|
||||
|
||||
if ($property === 'id' && $entity->id === null) {
|
||||
continue;
|
||||
}
|
||||
$type = $this->getParameterTypeForProperty($entity, $property);
|
||||
$qb->setValue($column, $qb->createNamedParameter($value, $type));
|
||||
}
|
||||
|
|
@ -116,7 +119,7 @@ abstract class QBMapper {
|
|||
/** @psalm-suppress DocblockTypeContradiction */
|
||||
$entity->generateId();
|
||||
$qb->executeStatement();
|
||||
} elseif ($entity->getId() === null) {
|
||||
} elseif ($entity->id === null) {
|
||||
$qb->executeStatement();
|
||||
// When autoincrement is used id is always an int
|
||||
$entity->setId($qb->getLastInsertId());
|
||||
|
|
|
|||
Loading…
Reference in a new issue