Needs work
Project:
Drupal core
Version:
main
Component:
base system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
7 Jan 2015 at 15:44 UTC
Updated:
20 Jun 2022 at 11:16 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
xavier_g commentedComment #2
xavier_g commentedOn second thought, it is probably better to provide a drupal_unserialize() function that takes care of checking the return of PHP's unserialize() and making it available to the caller through an extra parameter. The attached patch (drupal-unserialize.patch) achieves this.
Comment #3
pounardThat sounds like a nice idea.
Comment #4
socialnicheguru commentedComment #5
pounardSomething is bothering me in there, most of the time, unserialization errors comes from a system change (PHP version change, new PHP extension installed or uninstalled such as igbinary, or corrupted data in the storage level) and therefore, hiding them is hiding a potential unstable system.
My opinion is that the proposeddrupal_unserialize()method hide such errors and make a system problem being silent, and that's bad. It should at the bare minimum log it using theWATCHDOG_ERRORlevel to avoid making them silent.Ok didn't see that comment:
Comment #6
Antti J. Salminen commentedLooks like the same code still also exists in Drupal 8. Lack of any checking of unserialize() results also made #2565259: Some route serializations in update test database dumps are broken harder to debug.
#2216527: Inject a serialization format into database key/value storage added a serialization component and it could be possibly enhanced to check for the return value from unserialize() and used for these cases.
The attached patch does some of the work for 8.x. The original reporter mentioned the Drupal 7 equivalent of Drupal\Core\Cache\DatabaseBackend and I ran into this with Drupal\Core\Routing\RouteProvider so I converted those to using the PhpSerialize class in this. I included a test for RouteProvider because I initially created it before finding this issue and thinking of the wider picture.
Comment #19
lendudeLooking at old bug reports as part of the Bug Smash Initiative.
This seems like hardening to protect against bugs, but not a bug itself, so moving this to a Task for now.