Repository navigation
Prebuilt binaries require PHP 8.4.27+ / 8.5.12+; build from source on older patches.
Added
- PHP 8.6 prebuilt binaries, built against PHP 8.6.0: Windows (TS/NTS, x86 and x64), Linux glibc (x86_64, arm64), and macOS arm64.
Changed
phpser_serialize(),phpser_serialize_signed()andphpser_serialize_keyed()write a top-level null, bool, int, float, or string of at most 4 GiB straight into the result, without the encoder's string cache, dictionary or intermediate body buffer. On Linux x86-64 (GCC 14), thebench.php --extendedstring_15andint_singleshapes take 52-56% less encode time, a 4 KiB string 55% less and a 1 MiB string 91% less; signed encodes of the same small values take 7-17% less. Arrays, objects, references and strings over 4 GiB take the general path as before. Wire output and decoded values are unchanged.- The encoder's per-call string cache grows 4x instead of 2x while it has 2048 or fewer slots; above that it still doubles. An encode whose cache starts at 2048 or fewer slots (32 without a size hint) and caches more distinct strings than that starting size skips intermediate resizes: 2,239 strings take 5 resizes and 1,360 re-inserts instead of 9 and 4,080. One that resizes but caches no more than its starting size (17 to 32 strings without a hint) does the same single resize into a table twice as large. On the
bench.php --extendedapp shapes,catalogtakes 26-28% less encode time,eloquent_model11-13%,wallet8-12% andeloquent_coll_303-5%; the other measured shapes moved less than 4%. The cache can end up twice its previous size; at 1,025 entries that is 64 KiB more peak memory on 64-bit builds. Wire output and decoded values are unchanged. - Decoder string dictionaries allocate only their declared pointer slots, avoiding an unused sentinel slot and an extra allocator page at page-sized boundaries. Wire output and decoded values are unchanged.
- Repeated object, reference, and shared-array identities no longer grow the encoder identity table when it is half full, avoiding an unnecessary allocation and rehash. Wire output and decoded values are unchanged.
- An
allowed_classesoption that is neither an array nor a bool now throwsTypeErrorinstead ofValueErroron every supported PHP version, including 8.2 and 8.3, matching nativeunserialize(). Code that catchesValueErrorfor this case must catchTypeError.
Fixed
- Windows builds no longer refuse to start on a PHP patch release older than the one they were built against. The startup version check added in 0.10.2 now applies only on Linux and macOS, where a missing symbol would otherwise end the process mid-request; on Windows a missing symbol already fails when the DLL loads. The 0.10.2 and 0.10.3 Windows DLLs refuse to start on any earlier patch of their minor, so on Windows upgrade PHP to the latest patch or install the next release.
- On ZTS builds,
session.auto_start=1withsession.serialize_handler=phpserno longer crashes the first request on each new thread (FrankenPHP, embed SAPI); ext/session decoded the stored session before phpser had set up the thread. - On PHP 8.3 and later, encoding throws the engine's "Maximum call stack size"
Errorand decoding rejects the payload when the C stack runs low, instead of crashing; this covers deep nesting on small thread stacks, such as musl's 128 KiB default, and__serialize()methods that callphpser_serialize()recursively. The session handler warns and stores its encode-failure marker instead, as it does for over-deep values; when a nested__serialize()hook runs out of stack during the request-end auto-save, the engine still reports the uncaughtError, as it does for any exception thrown by a hook there. - A ZTS thread released through
ts_free_thread()now wipes its cached signing keys and derived subkeys before its thread-local storage is freed; before, only the thread running module shutdown wiped its copy. - Encoding an object with many properties, one whose
__sleep()returns a long member list, or rows that share a wide string-key schema now stops at a pending memory_limit error, so the request ends with the memory_limit fatal instead of the process exiting at the hard limit (PHP 8.2.35, 8.3.36, 8.4.27, 8.5.12 and later). - A long
allowed_classeslist passed to the unserialize functions now stops being copied at a pending memory_limit error, so the request ends with the memory_limit fatal instead of the process exiting at the hard limit (same PHP versions). - Match native
allowed_classesoption-type errors and PHP 8.4+ stringable entries and exact diagnostics, including PHP 8.6 embedded-NUL names. Retain the allowlist during string conversion; PHP 8.2/8.3 keep their string-only entry restriction. - Reject invalid class names in
allowed_classeswithValueErroron PHP 8.4 and later, matching nativeunserialize(), before any decode hooks run. This applies to plain, signed, and keyed decoding; PHP 8.2 and 8.3 behavior is unchanged. - On PHP 8.6,
__sleepwarnings and the anonymous-class "Serialization of ... is not allowed" exception now print names with embedded NUL bytes in full, as nativeserialize()does; phpser cut them at the first NUL, so a duplicate protected member was reported as"".