8000 Hotfix/issue #1565 sleep private properties by Ocramius · Pull Request #1 · Ocramius/hiphop-php · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Hotfix/issue #1565 sleep private properties #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions hphp/runtime/base/object-data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,11 +709,13 @@ void ObjectData::serializeImpl(VariableSerializer* serializer) const {
auto thiz = const_cast<ObjectData*>(this);
Array wanted = Array::Create();
Array props = ret.toArray();
Array vals = nullptr;
bool hasInaccessibleProperties = false;
for (ArrayIter iter(props); iter; ++iter) {
String name = iter.second().toString();
bool visible, accessible, unset;
thiz->getProp(m_cls, name.get(), visible, accessible, unset);
if (accessible && !unset) {
if (!unset) {
String propName = name;
Slot propInd = m_cls->getDeclPropIndex(m_cls, name.get(), accessible);
if (accessible && propInd != kInvalidSlot) {
Expand All @@ -724,8 +726,21 @@ void ObjectData::serializeImpl(VariableSerializer* serializer) const {
propName = concat4(s_zero, s_star, s_zero, name);
}
}
wanted.set(propName, const_cast<ObjectData*>(this)->
o_getImpl(name, RealPropUnchecked, true, o_getClassName()));
if (accessible) {
wanted.set(propName, const_cast<ObjectData*>(this)->
o_getImpl(name, RealPropUnchecked, true, o_getClassName()));
} else {
if (!hasInaccessibleProperties) {
hasInaccessibleProperties = true;
vals = o_toArray();
}
if (vals.exists(propName)) {
wanted.set(propName, vals.lvalAt(propName));
} else {
raise_warning("\"%s\" returned as member variable from "
"__sleep() but does not exist", name.data());
}
}
} else {
raise_warning("\"%s\" returned as member variable from "
"__sleep() but does not exist", name.data());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
class foo
{
private $private = 'private';
protected $protected = 'protected';
public $public = 'public';

public function __sleep()
{
return array("\0foo\0private", "\0*\0protected", 'public');
}
}

var_dump(str_replace("\0", '\0', serialize(new foo())));
?>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
string(114) "O:3:"foo":3:{s:12:"\0foo\0private";s:7:"private";s:12:"\0*\0protected";s:9:"protected";s:6:"public";s:6:"public";}"
0