Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
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 <[email protected]>
  • Loading branch information
Carl Schwan committed Jan 6, 2026
commit 693a2263ccad1404aa483a44eb73f5f4b85ee787
3 changes: 2 additions & 1 deletion lib/private/Authentication/Token/PublicKeyToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public function __construct() {
}

public function getId(): int {
return (int)$this->id;
assert(!is_string($this->id) && $this->id !== null);
return $this->id;
}

public function getUID(): string {
Expand Down
5 changes: 4 additions & 1 deletion lib/public/AppFramework/Db/QBMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ public function insert(Entity $entity): Entity {
$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));
}
Expand All @@ -116,7 +119,7 @@ public function insert(Entity $entity): Entity {
/** @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());
Expand Down
Loading