4.x
Security::permissionFailure() attempts to store a back URL in the session without checking whether a session is available on the request object:
This may result in an exception:
BadMethodCallException: "No session available for this HTTPRequest"
I believe this happened because the current request was a NullHTTPRequest. The setup that reached this error is a bit complex (it involves elemental + userforms + elemental-userforms + page access controls), but it鈥檚 a simple change to code defensively here.
Yeah, none of HTTPRequest indicates that getRequest() can return null, but I'm pretty sure it can. Do you think this would be a case of "if there's a session, run that logic, else ignore it" or something else like trying to get a session from somewhere else?
Do you think this would be a case of "if there's a session, run that logic, else ignore it" or something else like trying to get a session from somewhere else?
I think the first option is fine, we could achieve that by introducing a simple hasSession() method
Throwing an exception like that in the getter is a bit strange. I'm +1 for the hasSession method.
We can probably do both
Merged https://github.com/silverstripe/silverstripe-framework/pull/9152 but I鈥檒l leave this open until hasSession() is added to a minor release