This patch implements a workaround for a known bug in var_export() which fails to export stdClass objects correctly:

http://bugs.php.net/bug.php?id=48016&edit=1

You can see the #fail for yourself:

$foo = array(
  'object' => (object) (array(
    'foo' => 'bar',
  )),
);

$foo = var_export($foo, TRUE);
eval('$foo = '. $foo .';');

This workaround casts using (object) rather than the missing __set_state() method and only targets stdClass objects.

First noticed on #655362: Exporting object variables causes PHP fatal errors..

CommentFileSizeAuthor
ctools_var_export_stdclass.patch956 bytesyhahn

Comments

merlinofchaos’s picture

Status: Needs review » Fixed

Makes sense. Committed!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.