Repository navigation
Immutable
release. Only release title and notes can be modified.
Changed
deepclone_from_array()doesn't convert an object to a string anymore when
a payload puts it in astringproperty: it throws aTypeError, like
unserialize(). The conversion called__toString()on an object that
might not be hydrated yet, and crashed on aBcMath\Numberthat still
waits for its state.deepclone_hydrate()doesn't create a string anymore for each key that
names a protected or private property.deepclone_to_array()evaluates the constant expressions of a class once
per call to find the closures they declare. It did it again for each
closure, up to its declaration, running the constructors of attribute
arguments each time: exporting 20,000 objects that hold the same attribute
closure took 1.6 s, and takes 8 ms now.- On PHP 8.5 and 8.6,
ReflectionAttribute::newInstance()and
::getArguments()cost the same as without the extension for the
attributes that take literals only. For the others, the extension doesn't
build the property table of each object of the instance anymore, which
tripled the memory they use. It also skips scalars, enum cases and literal
arrays, and needs no table to remember the objects it went through:
instantiating an attribute that takes two objects costs 10% more than
without the extension, down from 37%. deepclone_to_array()scans nested arrays once to tell whether they can be
shared as is. It scanned them again at each level when one held an object:
400 levels of 200 scalars over an object took 20 ms, and take 3 ms now.deepclone_to_array()shares the state that__serialize()returns when
it holds scalars only, like it does for the arrays of properties. It copied
it before: one million integers took 30 ms and 17 MB.deepclone_to_array()removes the scope prefix from the names of protected
and private properties once per class, instead of once per object, and
looks the classes it met last up by address: exporting a graph of 5,700
objects that describe entities needs 11% fewer instructions.
Fixed
deepclone_to_array()crashed on astdClassobject whose property table
has integer keys.ArrayObjectwrites such keys to the object it wraps.deepclone_to_array()crashed when__sleep(),__serialize()or a lazy
initializer assigned a new value to a&reference of the graph that holds
the object being exported.deepclone_to_array()stops at the exception that an error handler throws
while it reads the state of an object. It went on before, and could replace
the exception with aNotInstantiableException.deepclone_to_array()ran the destructor of the instances it creates to
read the default values of a class. This happened for objects that have
dynamic properties or that were cast to array, eg byforeach, and made
the call fail when the destructor needed what the constructor sets.deepclone_to_array()merged the&references that__serialize()or
__sleep()create and release while the graph is walked, as their addresses
got reused: references are kept alive until the payload is built, like
objects.- The cycles of objects that
__serialize()creates were never collected
when the cycle collector ran duringdeepclone_to_array(). - For classes cached by OPcache,
deepclone_to_array()exported the
properties that hold a default value declared with a global constant or an
enum case, unlike without OPcache. deepclone_to_array()finds the private properties of anonymous classes
when__sleep()returns them by their mangled name.deepclone_hydrate()wrote to the property table that astdClassobject
shares with a clone, or with the array it was cast from or to: the write
changed them too.deepclone_hydrate()anddeepclone_from_array()could corrupt memory
when the destructor of a value they replace in astdClassobject, or in a
dynamic property bound to a reference, wrote to the same object.deepclone_hydrate()wrote to the lazy proxy itself once it is initialized,
instead of its real instance. On a lazy object that isn't initialized, the
default flags ran set hooks, and neither converted scalars to backed enums
nor leftnullproperties uninitialized.deepclone_hydrate()letnulluninitialize a readonly property, which
could then be written again, and bound readonly properties to references
withDEEPCLONE_HYDRATE_PRESERVE_REFS.deepclone_hydrate()loads the backed enum of a property when needed to
convert a scalar to its case. The conversion was skipped when the enum
wasn't loaded yet.deepclone_hydrate()calls__set()for an untyped property that was
unset, and writes through the reference that an untyped property holds,
likeReflectionProperty::setRawValue().- With
DEEPCLONE_HYDRATE_PRESERVE_REFS, the value of a reference is
converted like other values: to the type of the property, to the case of a
backed enum, andnullleaves the property uninitialized. - With
DEEPCLONE_HYDRATE_PRESERVE_REFS, binding a reference to a new dynamic
property triggers the "Creation of dynamic property" deprecation, like
writing a value does. - References bound to a typed property that a child class redeclares are
tracked by that property. Destroying the object could corrupt memory when
the reference was bound through the scope of the parent class. deepclone_hydrate()accepts the keys that an(array)cast gives to the
private properties of an anonymous class, whose name contains a NUL byte.deepclone_hydrate()rejects mangled keys forstdClassobjects, like for
other classes:"\0*\0foo"created a publicfooproperty.$allowed_classescan hold&references, eg after aforeachby
reference on the list, like theallowed_classesoption ofunserialize().- Called from
Serializable::unserialize(),deepclone_from_array()could
corrupt memory when the payload held an object exported as a serialized
string: unserializing it joined the context of the outerunserialize()
call. Such strings are now unserialized in a context of their own. - Called from
Serializable::serialize(),deepclone_to_array()exported
Serializableobjects as back-references to the stream of the outer
serialize()call, egr:2;, which nothing else can restore. They're
serialized in a context of their own too. - On PHP 8.4 and 8.5,
deepclone_hydrate()with
DEEPCLONE_HYDRATE_NO_LAZY_INITcould corrupt the memory of the next
request when user code called it while the request shuts down, eg from the
stream_close()of a stream wrapper or from the save handler of a session. deepclone_from_array()built a reference that holds itself for"refs"
that target each other with hard-reference markers in"refMasks", which
made the first use of the result loop forever. Such a reference takes the
value of its target now, and is rejected when it targets itself, also
through another reference.deepclone_from_array()throws when the stack limit is reached on deeply
nested values and masks, on PHP 8.4+. It crashed before.deepclone_from_array()rejects named closures over abstract methods:
calling one crashed for the methods of internal interfaces.- String keys in
"refs"are kept apart from reference ids. A string key
could take the place of an id that equals its hash. - When
deepclone_from_array()returns lazy ghosts, their properties aren't
bound to the&references that the payload itself holds anymore, like for
other objects. - On ZTS builds, first-class callables that an attribute declares over a
method of another class, or over a function, were only exported as
references to their declaration on the thread that started PHP. Other
threads, ie all requests with FrankenPHP, required$allow_named_closures. - The class that declares such a callable was remembered for the lifetime of
the process: a request that only loaded another class that declares the
same callable failed. - A callable over a static method called on a child class, eg
B::m(...),
was exported as theself::m(...)that its parent declares in a constant
expression, and restored as a call on the parent. - A closure over a method of a parent class, eg
parent::m(...), was
restored as a closure over the method that overrides it. Such closures are
exported with the class that declares the method, like the ones over
non-public methods. exit()was ignored when called whiledeepclone_to_array()evaluates the
constant expressions of a class, eg by the constructor of an attribute
argument.- With the extension loaded on PHP 8.5 and 8.6,
ReflectionAttribute::newInstance()threw anError, or didn't return,
when the instance holds an array that references itself. - When it reached the stack limit on deeply nested arrays,
deepclone_to_array()went on level after level, each one throwing again:
200,000 levels took 90 s and chained 16,000 errors. It throws once now. deepclone_from_array()replays the states of final internal classes like
BcMath\Numberbefore any user code runs. A payload that orders its states
another way thandeepclone_to_array()gave such an object to the
__unserialize()or__wakeup()of another one before it was initialized,
and reading aBcMath\Numberin that state crashes.