Re: Changes to SuperGlobals for PHP 8 (was: something about session_start...)
| From: | Rowan Collins | Date: | Fri, 28 Jul 2017 21:12:10 +0000 |
| Subject: | Re: Changes to SuperGlobals for PHP 8 (was: something about session_start...) | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-100093@lists.php.net to get a copy of this message | ||
Hi Sara,
>>> On Fri, Jul 28, 2017 at 5:45 PM, Sara Golemon <pollita@php.net>
>wrote:
>>>> ftr; I'd vote in favor of several BC breaking things to do with
>>>> autoglobals, among them:
>>>>
>>>> * Make them objects (though ArrayAccess based for less hostile BC
>>>> breakage)
>>>> * Make most of them read-only (offsetGet(), but no offsetSet)
>>>> * Make $_SESSION[...] access produce an error or auto-start the
>session
Yep, this is pretty much what I had in mind when I made that passing remark, but didn't want to
derail the thread. Now it has its own thread, however, I'm going to argue against myself and
say why I think this is the wrong direction. ;)
The obvious downside of changing request vars to read only is the huge body of code that writes to
them. This isn't all bad code: as rhsoft points out, testing any code that *reads* those vars
necessarily requires the harness to write to them; and a common way to *prevent* reading them is to
overwrite them with empty values.
More importantly, though, it's papering over the problem, which is that request information
shouldn't be global. There are other barriers to a threaded, event-based SAPI becoming core and
default, but a scoped request representation would be high up the todo list.
There was mention a while ago of discussion in the Python community of replacing WSGI with an even
more flexible interface for the HTTP2 era, supporting worker and server push models as well as
request-response. The suggestion was that PHP could learn from or even collaborate on that model.
Does anyone know its status?
Obviously, that's a much more ambitious project, but if we're talking 10 years to phase in
a breaking change, it would be good to at least attempt some future-proofing, rather than just
adding a few restrictions which were missed 10 years ago, and implicitly extending the lifetime of
the concept of global request data.
On a slight tangent, I consider $_SERVER to be a broken pile of "we'll just shove this in
here and hope for the best", and I will oppose any attempt to convert it into an object which
doesn't reorganize its keys to be sane, documented, and as cross-platform as the SAPI layer can
make it. :P
Regards,
--
Rowan Collins
[IMSoP]