Hi,
As Internal Class doesn't support newInstanceWithoutConstructor, some
user code use the above hack (ex phpunit-mock-object)
$object = unserialize(
sprintf('%s:%d:"%s":0:{}',
(version_compare(PHP_VERSION, '5.4', '>')
&& $class->implementsInterface("Serializable") ? "C" : "O"),
strlen($className),
$className
)
);
Of course, this is already a hack.
Of course, better solution will be to support
newInstanceWithoutConstructor for all internals classes, but this is
another story
Problem, Serializable internal class raised the
'Empty serialized string cannot be empty' exception.
I don't really see any reason to make serialized string mandatory, as
those classes can be create (constructor) without any mandatory option.
The trivial attached patch could make everyone life easier.
The new test serialize again the result object to ensure all internal
structures are properly initialized, and no segfault.
Feedback welcome.
Remi.
Hi,
As Internal Class doesn't support newInstanceWithoutConstructor, some
user code use the above hack (ex phpunit-mock-object)$object = unserialize(
sprintf('%s:%d:"%s":0:{}',
(version_compare(PHP_VERSION, '5.4', '>')
&& $class->implementsInterface("Serializable") ? "C" : "O"),
strlen($className),
$className
)
);Of course, this is already a hack.
Of course, better solution will be to support
newInstanceWithoutConstructor for all internals classes, but this is
another storyProblem, Serializable internal class raised the
'Empty serialized string cannot be empty' exception.I don't really see any reason to make serialized string mandatory, as
those classes can be create (constructor) without any mandatory option.The trivial attached patch could make everyone life easier.
The new test serialize again the result object to ensure all internal
structures are properly initialized, and no segfault.Feedback welcome.
Remi.
--
--
I'm +1 on this change, would like to hear what others think.
ps: small typo in the patch:
Check that SplObjectStorage::unserialize desn't throws exception when NULL
passed
should be
Check that SplObjectStorage::unserialize doesn't throw exception when NULL
passed
imo
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
Hi,
As Internal Class doesn't support newInstanceWithoutConstructor, some
user code use the above hack (ex phpunit-mock-object)$object = unserialize(
sprintf('%s:%d:"%s":0:{}',
(version_compare(PHP_VERSION, '5.4', '>')
&& $class->implementsInterface("Serializable") ? "C" : "O"),
strlen($className),
$className
)
);Of course, this is already a hack.
Of course, better solution will be to support
newInstanceWithoutConstructor for all internals classes, but this is
another storyProblem, Serializable internal class raised the
'Empty serialized string cannot be empty' exception.I don't really see any reason to make serialized string mandatory, as
those classes can be create (constructor) without any mandatory option.The trivial attached patch could make everyone life easier.
The new test serialize again the result object to ensure all internal
structures are properly initialized, and no segfault.Feedback welcome.
Remi.
--
--
I'm +1 on this change, would like to hear what others think.
ps: small typo in the patch:
Check that SplObjectStorage::unserialize desn't throws exception whenNULL
passed
should be
Check that SplObjectStorage::unserialize doesn't throw exception whenNULL
passed
imo
I'm also +1, but better wait for Etienne's answer about those strings.
If he used such a code, I guess there was a reason, if we effectively
can get rid of them with no hidden bug, then go for it
Julien P