I’m slightly confused by the behavior/implementation of the flashNow() method in mezzio-flash. My context is mezzio-flash on top of mezzio-session using psr7-session/storageless[-mezzio-integration].
The behavior I’m getting is that if I set a message with flashNow(), and display it later in the same request, it also persists until the next request.
The description in the method comment on flashNow() suggests this is intended ( " … during the current request as well"):
/**
* Set a flash value with the given key, but allow access during this request.
*
* Flash values are generally accessible only on subsequent requests;
* using this method, you may make the value available during the current
* request as well.
*
* @param mixed $value
*/
public function flashNow(string $key, $value, int $hops = 1): void
{
$this->currentMessages[$key] = $value;
$this->flash($key, $value, $hops);
}
I’m having a hard time deciding if that’s actually intended or not. If it is, I’m not seeing the use-case.
My expectation is that messages set via flashNow()
would only be available to the current request, or in the alternative, available in the current xor next request - but never both. Removing the call to $this->flash()
in the method excerpted above gets me the behavior that meets my expectation.
Am I missing a use case here? If this is a bug, I’m kind of astonished, and don’t see an elegant way to fix it without breaking BC.