Skip to content

Commit 8737eee

Browse files
committed
Allow serializing actions before they were first executed
That way, they can be stashed away while the user is still logging in (which requires a separate `DialogInitialization` action).
1 parent fec22a6 commit 8737eee

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

lib/Fhp/BaseAction.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ abstract class BaseAction implements \Serializable
6161
*
6262
* NOTE: A common mistake is to call this function directly. Instead, you probably want `serialize($instance)`.
6363
*
64-
* An action can only be serialized *after* it has been executed in case it needs a TAN, i.e. when the result is not
65-
* present yet.
64+
* An action can only be serialized before it was completed.
6665
* If a sub-class overrides this, it should call the parent function and include it in its result.
6766
* @return string The serialized action, e.g. for storage in a database. This will not contain sensitive user data.
6867
*/
@@ -72,17 +71,16 @@ public function serialize(): string
7271
}
7372

7473
/**
75-
* An action can only be serialized *after* it has been executed in case it needs a TAN, i.e. when the result is not
76-
* present yet.
74+
* An action can only be serialized before it was completed.
7775
* If a sub-class overrides this, it should call the parent function and include it in its result.
7876
*
7977
* @return array The serialized action, e.g. for storage in a database. This will not contain sensitive user data.
8078
* Note that this is not necessarily valid UTF-8, so you should store it as a BLOB column or raw bytes.
8179
*/
8280
public function __serialize(): array
8381
{
84-
if (!$this->needsTan()) {
85-
throw new \RuntimeException('Cannot serialize this action, because it is not waiting for a TAN.');
82+
if ($this->isDone()) {
83+
throw new \RuntimeException('Completed actions cannot be serialized.');
8684
}
8785
return [
8886
$this->requestSegmentNumbers,

0 commit comments

Comments
 (0)