From b2f7473aeb6cfca9a220e9932602deb985449a82 Mon Sep 17 00:00:00 2001 From: mwilliams Date: Tue, 2 Jul 2013 15:52:14 -0700 Subject: [PATCH] Fix var_export for resources Debug builds hit an assert, and release builds would output something like array(}. --- hphp/runtime/base/variable_serializer.cpp | 3 ++- hphp/test/slow/var_export/resource.php | 8 ++++++++ hphp/test/slow/var_export/resource.php.expect | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 hphp/test/slow/var_export/resource.php create mode 100644 hphp/test/slow/var_export/resource.php.expect diff --git a/hphp/runtime/base/variable_serializer.cpp b/hphp/runtime/base/variable_serializer.cpp index d6fa899d7..4eb3dfa78 100644 --- a/hphp/runtime/base/variable_serializer.cpp +++ b/hphp/runtime/base/variable_serializer.cpp @@ -69,6 +69,7 @@ void VariableSerializer::getResourceInfo(String &rsrcName, int &rsrcId) { void VariableSerializer::setResourceInfo(CStrRef rsrcName, int rsrcId) { m_rsrcName = rsrcName; m_rsrcId = rsrcId; + m_objCode = 0; } String VariableSerializer::serialize(CVarRef v, bool ret) { @@ -849,7 +850,7 @@ void VariableSerializer::writeArrayFooter() { case Type::VarExport: case Type::PHPOutput: indent(); - if (info.is_object) { + if (info.is_object && m_objCode) { if (m_objCode == 'O') { m_buf->append("))"); } else { diff --git a/hphp/test/slow/var_export/resource.php b/hphp/test/slow/var_export/resource.php new file mode 100644 index 000000000..dffd539b1 --- /dev/null +++ b/hphp/test/slow/var_export/resource.php @@ -0,0 +1,8 @@ +