From 41cc89280ec8c21638fe6d4931ef145b103b5caa Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Mon, 30 Mar 2015 15:30:33 +0200 Subject: add PHPCPP_EXPORT macros to a number of << operators to prevent undefined symbol errors, Value::contains() now also works with __isset() --- include/hashmember.h | 4 ++-- include/value.h | 2 +- zend/value.cpp | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/include/hashmember.h b/include/hashmember.h index 12ee385..378ee90 100644 --- a/include/hashmember.h +++ b/include/hashmember.h @@ -611,8 +611,8 @@ private: * @param value * @return ostream */ -std::ostream &operator<<(std::ostream &stream, const HashMember &value); -std::ostream &operator<<(std::ostream &stream, const HashMember &value); +PHPCPP_EXPORT std::ostream &operator<<(std::ostream &stream, const HashMember &value); +PHPCPP_EXPORT std::ostream &operator<<(std::ostream &stream, const HashMember &value); /** diff --git a/include/value.h b/include/value.h index 40327cd..29b64af 100644 --- a/include/value.h +++ b/include/value.h @@ -1204,7 +1204,7 @@ protected: * @param value * @return ostream */ -std::ostream &operator<<(std::ostream &stream, const Value &value); +PHPCPP_EXPORT std::ostream &operator<<(std::ostream &stream, const Value &value); /** * Custom +=, -=, *=, /=, &= operators, to update integral types with a Php::Value diff --git a/zend/value.cpp b/zend/value.cpp index 0d1f840..f98ac10 100644 --- a/zend/value.cpp +++ b/zend/value.cpp @@ -1489,8 +1489,18 @@ bool Value::contains(const char *key, int size) const // retrieve the object pointer and check whether the property we are trying to retrieve is marked as private/protected if (zend_check_property_access(zend_objects_get_address(_val TSRMLS_CC), key, size TSRMLS_CC) == FAILURE) return false; - // check if the property is set inside the hashtable of the object - return zend_hash_find(Z_OBJPROP_P(_val), key, size+1, (void **)&result) != FAILURE; + // check if the 'has_property' method is available for this object + auto *has_property = Z_OBJ_HT_P(_val)->has_property; + + // leap out if no 'has_property' function is not set (which should normally not occur) + if (!has_property) return false; + + // the property must be a zval, turn the key into a value + Value property(key, size); + + // call the has_property() method (0 means: check whether property exists and is not NULL, + // this is not really what we want, but the closest to the possible values of that parameter) + return has_property(_val, property._val, 0, nullptr TSRMLS_CC); } else { -- cgit v1.2.3