diff options
author | Mark Spruiell <mes@zeroc.com> | 2007-06-19 11:25:17 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2007-06-19 11:25:17 -0700 |
commit | ddcfe70b4f05fb00e466486fc19076147f79298d (patch) | |
tree | acfa4428263b22b3f9226d04a3fe8f910bd21bdd /php/src/IcePHP/Marshal.cpp | |
parent | For UDP multicast bind to the multicast address rather than 0.0.0.0 unless on... (diff) | |
download | ice-ddcfe70b4f05fb00e466486fc19076147f79298d.tar.bz2 ice-ddcfe70b4f05fb00e466486fc19076147f79298d.tar.xz ice-ddcfe70b4f05fb00e466486fc19076147f79298d.zip |
bug 2245 - adding support for protected class data members
Diffstat (limited to 'php/src/IcePHP/Marshal.cpp')
-rw-r--r-- | php/src/IcePHP/Marshal.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/php/src/IcePHP/Marshal.cpp b/php/src/IcePHP/Marshal.cpp index 0671b484da8..8b0f6118d73 100644 --- a/php/src/IcePHP/Marshal.cpp +++ b/php/src/IcePHP/Marshal.cpp @@ -1247,12 +1247,25 @@ IcePHP::MemberMarshaler::unmarshal(zval* zv, const Ice::InputStreamPtr& is TSRML return false; } - if(add_property_zval(zv, const_cast<char*>(_name.c_str()), val) == FAILURE) + // + // The add_property_zval function fails if the data member has protected visibility. + // As a workaround, before calling the function we change the current scope to be that + // of the object. + // + zend_class_entry *oldScope = EG(scope); + EG(scope) = Z_OBJCE_P(zv); + + int status = add_property_zval(zv, const_cast<char*>(_name.c_str()), val); + + EG(scope) = oldScope; // Restore the previous scope. + + if(status == FAILURE) { php_error_docref(0 TSRMLS_CC, E_ERROR, "unable to set member `%s'", _name.c_str()); return false; } - zval_ptr_dtor(&val); // add_property_zval increments the refcount + + zval_ptr_dtor(&val); // add_property_zval increments the refcount. return true; } |