[RFC] Restrict $GLOBALS usage

php.internals

Nikita Popov

5 years ago
Hi internals, I would like to propose the following RFC, which restricts certain rare usages of $GLOBALS. This change will improve performance, reduce internal implementation complexity, and fix a very large class of bugs relating to $GLOBALS handling in internal functions. https://wiki.php.net/rfc/restrict_globals_usage Regards, Nikita

Nicolas Grekas

5 years ago
Hello Nikita,
> I would like to propose the following RFC, which restricts certain rare > usages of $GLOBALS. This change will improve performance, reduce internal > implementation complexity, and fix a very large class of bugs relating to > $GLOBALS handling in internal functions. > > https://wiki.php.net/rfc/restrict_globals_usage
Yes please! This will allow removing some black magic from Symfony's VarDumper component, which detects these "copies" of $GLOBALS: https://github.com/symfony/symfony/blob/31ee43a8c67897a2f61782060965f5c8a81f58a2/src/Symfony/Component/VarDumper/Cloner/VarCloner.php#L144-L155 Nicolas

Hans Henrik Bergan

5 years ago
if this gets rid of a significant amount of implementation complexity or runtime overhead, i'm all for it, and don't think i've ever seen code like $GLOBALS = []; before, given that it's technically a BC break, would have been nice as a 8.0.0 thing, but i hope it's small enough for an 8.x instead of waiting for php9 On Fri, 4 Dec 2020 at 12:04, Nicolas Grekas <nicolas.grekas+php@gmail.com> wrote:

Christoph Becker

5 years ago
On 04.12.2020 at 11:52, Nikita Popov wrote:
> I would like to propose the following RFC, which restricts certain rare > usages of $GLOBALS. This change will improve performance, reduce internal > implementation complexity, and fix a very large class of bugs relating to > $GLOBALS handling in internal functions. > > https://wiki.php.net/rfc/restrict_globals_usage
In my opinion, especially the last reason (fixing and preventing bugs related to missing IS_INDIRECT handling) makes this change particularly desireable. Regards, Christoph

Paul M. Jones

5 years ago
> On Dec 4, 2020, at 04:52, Nikita Popov <nikita.ppv@gmail.com> wrote: > > Hi internals, > > I would like to propose the following RFC, which restricts certain rare > usages of $GLOBALS. This change will improve performance, reduce internal > implementation complexity, and fix a very large class of bugs relating to > $GLOBALS handling in internal functions. > > https://wiki.php.net/rfc/restrict_globals_usage >
Big +1
-- Paul M. Jones pmjones@pmjones.io http://paul-m-jones.com Modernizing Legacy Applications in PHP https://leanpub.com/mlaphp Solving the N+1 Problem in PHP https://leanpub.com/sn1php

Sebastian Bergmann

5 years ago
Am 04.12.2020 um 11:52 schrieb Nikita Popov:
> https://wiki.php.net/rfc/restrict_globals_usage
Yes, please. The code you found in PHPUnit (both PHPUnit itself as well as sebastian/global-state) that would be affected by this can probably be removed (in a future version of PHPUnit that requires PHP >= 8.1).

Nikita Popov

5 years ago
On Fri, Dec 4, 2020 at 11:52 AM Nikita Popov <nikita.ppv@gmail.com> wrote:
> Hi internals, > > I would like to propose the following RFC, which restricts certain rare > usages of $GLOBALS. This change will improve performance, reduce internal > implementation complexity, and fix a very large class of bugs relating to > $GLOBALS handling in internal functions. > > https://wiki.php.net/rfc/restrict_globals_usage > > Regards, > Nikita >
Looks like this isn't particularly controversial, so I plan to start voting on this RFC soon. Nikita