Re: RFC: Server-Side Request and Response Objects (v2)
| From: | Paul M. Jones | Date: | Sat, 07 Mar 2020 22:50:12 +0000 |
| Subject: | Re: RFC: Server-Side Request and Response Objects (v2) | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-108894@lists.php.net to get a copy of this message | ||
Hi Arvids,
> On Mar 5, 2020, at 05:19, Arvids Godjuks <arvids.godjuks@gmail.com> wrote:
>
> one question I do have here is about how PHP-PM process manager will be
> able to interact with this layer?
> Cause right now it does rewrite the $_SERVER variable for each incoming
> request for its child processes that handle the requests
>
> https://github.com/php-pm/php-pm/blob/a2872e13c3901401d5c2386a8ed62502db23d5f2/src/ProcessSlave.php#L463
>
> It kind'a makes this not possible if there is no way to re-init the object.
> While read-only is, obviously, a good idea, there are some caveats like
> this that not only limit the possibilities but also what will the
> ServerRequest object even look like when $_SERVER is being rewritten like
> this?
>
> ...
>
> it seems that this RFC does not allow such usage at all and long-running processing has not
> been taken into account at all?
I have never used PHP-PM, so I am talking outside my competence here.
Even so, I see the ProcessSlave::prepareEnvironment() method rewrites $_SERVER. Instead of
re-initializing an existing object, would it be sufficient to create a new ServerRequest object
after that point, with the newly-modified $GLOBALS values (in which $_SERVER is represented)? You
would then use that new instance in the new child process.
Regarding a long-running process, I could see where the entry point might create a new instance of
ServerRequest as needed, using the current $GLOBALS state, and pass that new instance into whatever
handler gets invoked.
I am probably missing your point; if so, my apologies, and please guide me.
--
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