Alpha ZealPHP is early-stage and under active development. APIs may change between minor versions until v1.0. Feedback and bug reports welcome on GitHub.
API Index — Namespaces, Packages, Reports, Indices

ZealPHP_Pool_State
in package

FinalYes

Loop control and the response channel, kept out of the included script's reach (C1).

The request include runs at GLOBAL scope (legacy apps need their top-level variables to be real globals), so anything the loop keeps in a global the script can overwrite. These used to be $__pw_max_requests, $__pw_count, $__pw_fd3 and $__pw_mid_request: nulling $__pw_fd3 sent the response down a channel the parent no longer reads, and rewinding $__pw_count defeated the recycle. Private statics of a final class cannot be reached by ordinary code. (Reflection can still reach them: this guards against bugs, not against a hostile script, which the pool does not claim to contain.)

The class also carries the per-request token the parent sends with every request frame. Every response frame echoes it, so the parent can tell its own subprocess's frame from bytes some script wrote to fd 3.

#467 — $__pw_count / $__pw_max_requests were themselves the fix for an unprefixed $count the included app clobbered; moving them here closes the same hole for good.

Table of Contents

Properties

$count  : int
$fd3  : resource|null
$maxRequests  : int
$midRequest  : bool
$token  : string

Methods

boot()  : void
midRequest()  : bool
more()  : bool
read()  : array<string|int, mixed>|null
Read the next request frame. The token is taken out and kept here, so the included script never sees it.
respond()  : void
Send the response for the current request (metadata frame, then body) and leave the mid-request state. Called once per request: by the loop, or by ZealPHP_IPC_Sender's destructor when exit() cut the request short.
served()  : void

Properties

$midRequest

private static bool $midRequest = \false

Methods

midRequest()

public static midRequest() : bool
Return values
bool

more()

public static more() : bool
Return values
bool

read()

Read the next request frame. The token is taken out and kept here, so the included script never sees it.

public static read() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

respond()

Send the response for the current request (metadata frame, then body) and leave the mid-request state. Called once per request: by the loop, or by ZealPHP_IPC_Sender's destructor when exit() cut the request short.

public static respond(array<string|int, mixed> $resp, string $body) : void
Parameters
$resp : array<string|int, mixed>
$body : string
On this page