- Issue created by @benjifisher
- πΊπΈUnited States greggles Denver, Colorado, USA
benjifisher β credited greggles β .
- π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
benjifisher β credited larowlan β .
- π¬π§United Kingdom mcdruid π¬π§πͺπΊ
benjifisher β credited mcdruid β .
- πΊπΈUnited States benjifisher Boston area
I think it is all right to allow
stClass
, but tests are passing with['allowed_classes' => FALSE]
, so let's at least consider that.Does this issue need a change record? If there are any contrib or custom modules that extend the
DatabaseStorage
class, and they need to allow other classes inunserialize()
, then the good news is that they can easily override thedecode()
method, which is nowpublic function decode($raw) { $data = @unserialize($raw, ['allowed_classes' => FALSE]); return is_array($data) ? $data : FALSE; }
- πΊπΈUnited States smustgrave
I see there is one more @unserialize is that impacted?
- πΊπΈUnited States benjifisher Boston area
This issue is scoped to the Config system, and I think there is only one:
$ grep -ri unserialize core/lib/Drupal/Core/Config core/lib/Drupal/Core/Config/DatabaseStorage.php: * The unserialize() call will trigger E_NOTICE if the string cannot core/lib/Drupal/Core/Config/DatabaseStorage.php: * be unserialized. core/lib/Drupal/Core/Config/DatabaseStorage.php: $data = @unserialize($raw);
Did I miss something or are you thinking of something outside the Config system?
- πΊπΈUnited States smustgrave
No just saw this other instance and didn't know if it had the same problem.
- πΊπΈUnited States benjifisher Boston area
Then I guess you mean the usage in the
dblog
module:$ grep -ri @unserialize core core/modules/dblog/src/Controller/DbLogController.php: $variables = @unserialize($row->variables); core/lib/Drupal/Core/Config/DatabaseStorage.php: $data = @unserialize($raw);
The
@
just tells PHP to ignore errors fromserialize()
: see Error Control Operators in the PHP docs. There are many other calls toserialize()
in Drupal core.In the long run, we should switch to using
json_encode()
andjson_decode()
(or the equivalent methods inDrupal\Component\Serialization\Json
) whenever possible instead ofserialize()
andunserialize()
. In the short run, it is less disruptive to specifyallowed_classes
. - πΊπΈUnited States smustgrave
Not 100% how else to test so am relying on tests, which are green. Locally nothing seems broken so going to go on a limb