Skip to content

Commit

Permalink
fix(signed-request): trigger metadata insert with default value manually
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl committed Dec 4, 2024
1 parent c77243d commit ef4f24b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/private/Security/Signature/SignatureManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private function confirmIncomingRequestSignature(
if ($ttlSignatory > 0 && $knownSignatory->getLastUpdated() < (time() - $ttlSignatory)) {
$signatory = $this->getSaneRemoteSignatory($signatoryManager, $signedRequest);
$this->updateSignatoryMetadata($signatory);
$knownSignatory->setMetadata($signatory->getMetadata());
$knownSignatory->setMetadata($signatory->getMetadata() ?? []);
}

$signedRequest->setSignatory($knownSignatory);
Expand Down Expand Up @@ -353,6 +353,7 @@ private function insertSignatory(Signatory $signatory): void {
$time = time();
$signatory->setCreation($time);
$signatory->setLastUpdated($time);
$signatory->setMetadata($signatory->getMetadata() ?? []); // trigger insert on field metadata using current or default value
$this->mapper->insert($signatory);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/unstable/Security/Signature/Model/Signatory.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* @method void setAccount(string $account)
* @method string getAccount()
* @method void setMetadata(array $metadata)
* @method array getMetadata()
* @method ?array getMetadata()
* @method void setCreation(int $creation)
* @method int getCreation()
* @method void setLastUpdated(int $creation)
Expand All @@ -59,7 +59,7 @@ class Signatory extends Entity implements JsonSerializable {
protected string $account = '';
protected int $type = 9;
protected int $status = 1;
protected array $metadata = [];
protected ?array $metadata = null;
protected int $creation = 0;
protected int $lastUpdated = 0;

Expand Down

0 comments on commit ef4f24b

Please sign in to comment.