You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromGlobals() is meant to be used for requests parsed by php and injected into process as global variables. That rules out multiple requests in long running processes or requests assembled for testing.
Other than apparent misuse, this looks like a legit issue.
I would definitely consider a patch that uses the isset-ternary approach outlined above. That said, as noted by @Xerkus, this is a rare possibility in standard usage.
In
ServerRequestFactory::fromGlobals()
, most of the code checks if the arguments are truthy, rather than set. For example:https://github.com/zendframework/zend-diactoros/blob/89d471cc09850c7d47839cf16ba7a1fed54d45e5/src/ServerRequestFactory.php#L57-L58
https://github.com/zendframework/zend-diactoros/blob/89d471cc09850c7d47839cf16ba7a1fed54d45e5/src/ServerRequestFactory.php#L72-L74
This becomes an issue during testing (or a long-running process that accepts multiple requests). For example:
Improved versions would be:
Or for under PHP 7:
(This code should fix the issues, but I didn't have time to write any tests right now, so I'm opening an issue instead of a pr.)
Originally posted by @0b10011 at zendframework/zend-diactoros#281
The text was updated successfully, but these errors were encountered: