Previously we didn't register states before reconstituting them from events (like if a snapshot was removed)
If an apply method used $this->state(SomeState::class) it would attempt to reconstitute the state WHILE reconstituting the state (because it didn't find an instance in the cache). This would cause an infinite loop.
This PR just registers the state with the StateInstanceCache before it begins running the hooks so that there is an instance in the cache if any of the hooks require one.
Previously we didn't register states before reconstituting them from events (like if a snapshot was removed)
If an apply method used
$this->state(SomeState::class)
it would attempt to reconstitute the state WHILE reconstituting the state (because it didn't find an instance in the cache). This would cause an infinite loop.This PR just registers the state with the
StateInstanceCache
before it begins running the hooks so that there is an instance in the cache if any of the hooks require one.