Re: Re: Request lifecycle hooks for SAPIs that serve multiple requests per script (like FrankenPHP in worker mode)
| From: | Larry Garfield | Date: | Fri, 30 Oct 2026 13:42:23 +0000 |
| Subject: | Re: Re: Request lifecycle hooks for SAPIs that serve multiple requests per script (like FrankenPHP in worker mode) | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-132977@lists.php.net to get a copy of this message | ||
On Fri, Oct 30, 2026, at 7:51 AM, Kévin Dunglas wrote:
> After an off-list discussion with Tim Düsterhus, I'm retracting some
> of the examples from my first email: http_get_last_response_headers(),
> the libxml errors, error_get_last() and strtok(). They don't depend on
> the incoming HTTP request, so a worker SAPI shouldn't reset them
> between "logical" requests. Like any other state shared in worker
> mode, userland can clear them when needed with the existing functions
> (http_clear_last_response_headers(), libxml_clear_errors(),
> error_clear_last()).
>
> The rule I'm proposing is narrower: reset only the state built from
> the incoming request or tied to its response. The session module and
> output_add_rewrite_var() still fall under it.
>
> The main point of the proposal stands: hooks for "logical" requests
> give extensions one abstraction that works with every SAPI that has a
> worker mode, instead of special-casing each one.
>
> FrankenPHP will follow the same rule in its next release.
>
> Tim suggested a short RFC. I'll write it soon.
Bottom post, please. :-)
I'm still a bit fuzzy on how this would interact with Scopes. Specifically, I presume we would
want the user-space definition of "request lifetime" and the engine-space definition of
"request lifetime" to be in sync.. But as you note, Scopes as proposed don't have a
clear and obvious The End that can correspond to firing the request end hook. So what would that
coordination look like? Some contrived code samples would probably help.
--Larry Garfield