Check expiry on stage

This commit is contained in:
Jake Barnby 2025-10-09 23:37:44 +13:00
parent a3103bf4d4
commit 32d6eaa21c
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C
7 changed files with 42 additions and 0 deletions

View file

@ -105,6 +105,12 @@ class Decrement extends Action
throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Invalid or nonpending transaction');
}
$now = new \DateTime();
$expiresAt = new \DateTime($transaction->getAttribute('expiresAt', 'now'));
if ($now > $expiresAt) {
throw new Exception(Exception::TRANSACTION_EXPIRED);
}
// Enforce max operations per transaction
$maxBatch = $plan['databasesTransactionSize'] ?? APP_LIMIT_DATABASE_TRANSACTION;
$existing = $transaction->getAttribute('operations', 0);

View file

@ -105,6 +105,12 @@ class Increment extends Action
throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Invalid or nonpending transaction');
}
$now = new \DateTime();
$expiresAt = new \DateTime($transaction->getAttribute('expiresAt', 'now'));
if ($now > $expiresAt) {
throw new Exception(Exception::TRANSACTION_EXPIRED);
}
// Enforce max operations per transaction
$maxBatch = $plan['databasesTransactionSize'] ?? APP_LIMIT_DATABASE_TRANSACTION;
$existing = $transaction->getAttribute('operations', 0);

View file

@ -375,6 +375,12 @@ class Create extends Action
throw new Exception(Exception::TRANSACTION_NOT_READY);
}
$now = new \DateTime();
$expiresAt = new \DateTime($transaction->getAttribute('expiresAt', 'now'));
if ($now > $expiresAt) {
throw new Exception(Exception::TRANSACTION_EXPIRED);
}
// Enforce max operations per transaction
$maxBatch = $plan['databasesTransactionSize'] ?? APP_LIMIT_DATABASE_TRANSACTION;
$existing = $transaction->getAttribute('operations', 0);

View file

@ -137,6 +137,12 @@ class Delete extends Action
throw new Exception(Exception::TRANSACTION_NOT_READY);
}
$now = new \DateTime();
$expiresAt = new \DateTime($transaction->getAttribute('expiresAt', 'now'));
if ($now > $expiresAt) {
throw new Exception(Exception::TRANSACTION_EXPIRED);
}
// Enforce max operations per transaction
$maxBatch = $plan['databasesTransactionSize'] ?? APP_LIMIT_DATABASE_TRANSACTION;
$existing = $transaction->getAttribute('operations', 0);

View file

@ -252,6 +252,12 @@ class Update extends Action
throw new Exception(Exception::TRANSACTION_NOT_READY);
}
$now = new \DateTime();
$expiresAt = new \DateTime($transaction->getAttribute('expiresAt', 'now'));
if ($now > $expiresAt) {
throw new Exception(Exception::TRANSACTION_EXPIRED);
}
// Enforce max operations per transaction
$maxBatch = $plan['databasesTransactionSize'] ?? APP_LIMIT_DATABASE_TRANSACTION;
$existing = $transaction->getAttribute('operations', 0);

View file

@ -261,6 +261,12 @@ class Upsert extends Action
throw new Exception(Exception::TRANSACTION_NOT_READY);
}
$now = new \DateTime();
$expiresAt = new \DateTime($transaction->getAttribute('expiresAt', 'now'));
if ($now > $expiresAt) {
throw new Exception(Exception::TRANSACTION_EXPIRED);
}
// Enforce max operations per transaction
$maxBatch = $plan['databasesTransactionSize'] ?? APP_LIMIT_DATABASE_TRANSACTION;
$existing = $transaction->getAttribute('operations', 0);

View file

@ -77,6 +77,12 @@ class Create extends Action
throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Invalid or nonpending transaction');
}
$now = new \DateTime();
$expiresAt = new \DateTime($transaction->getAttribute('expiresAt', 'now'));
if ($now > $expiresAt) {
throw new Exception(Exception::TRANSACTION_EXPIRED);
}
$maxBatch = $plan['databasesTransactionSize'] ?? APP_LIMIT_DATABASE_TRANSACTION;
$existing = $transaction->getAttribute('operations', 0);