summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToon Schoenmakers <toon.schoenmakers@copernica.com>2015-10-07 17:21:38 +0200
committerToon Schoenmakers <toon.schoenmakers@copernica.com>2015-10-07 17:21:38 +0200
commit0ef1b5e130f300dab0ae06b67b44b33da7274a97 (patch)
treec9db3827fc5de2c1cae12f22f3d16bc9d30e2264
parentaacc2d56ce89cfb65adbc3225e323f4ba32ca2fa (diff)
Revert "Revert "Revert "Fix issue with derived classes, but only fix it for PHP 5.4 and up. Closes #211"""v1.5.1
This reverts commit c512e02a4031f4c359e60d637e0c86e8d9084646.
-rw-r--r--zend/classimpl.cpp38
1 files changed, 5 insertions, 33 deletions
diff --git a/zend/classimpl.cpp b/zend/classimpl.cpp
index b0d69a9..ad7dab4 100644
--- a/zend/classimpl.cpp
+++ b/zend/classimpl.cpp
@@ -38,27 +38,11 @@ ClassImpl::~ClassImpl()
*/
static ClassImpl *self(zend_class_entry *entry)
{
-#if PHP_VERSION_ID >= 50400
-
- /**
- * somebody could have extended this class from PHP userland, in which
- * case trying to dereference the doc_comment would result in a disaster
- * because it does not point to a class implemented by PHP-CPP at all!
- *
- * if this happens we need to keep going until we find the object that
- * was implemented by us. For this we are going to make the assumption
- * that we are the only ones misusing the doc_comment the way we do.
- *
- * Usually the doc_comment is not set (it equals the nullptr) and if it
- * is set, the accompanying doc_comment_len should be non-zero to
- * indicate the number of characters in it.
- */
- while (entry->parent && entry->info.user.doc_comment == nullptr && entry->info.user.doc_comment_len == 0)
- {
- // we did not create this class entry, but luckily we have a parent
- entry = entry->parent;
- }
+ // we need the base class (in user space the class may have been overridden,
+ // but we are not interested in these user space classes)
+ while (entry->parent) entry = entry->parent;
+#if PHP_VERSION_ID >= 50400
// retrieve the comment (it has a pointer hidden in it to the ClassBase object)
const char *comment = entry->info.user.doc_comment;
@@ -66,18 +50,6 @@ static ClassImpl *self(zend_class_entry *entry)
// the next bytes contain a pointer to the ClassBase class
return *((ClassImpl **)(comment + 1));
#else
-
- /**
- * This is likely not correct: If the class was extended using PHP-CPP
- * itself, we should retrieve the ClassImpl directly, however there is
- * no sane way to check this here, unlike in PHP 5.4.
- *
- * We therefore always go to the very base, of which we are sure that
- * we are the implementers. This way - at least - we don't cause any
- * segfaults.
- */
- while (entry->parent) entry = entry->parent;
-
// on php 5.3 we store the pointer to impl after the name in the entry
ClassImpl** impl = (ClassImpl**)(entry->name + 1 + entry->name_length);
@@ -504,7 +476,7 @@ int ClassImpl::cast(zval *val, zval *retval, int type TSRMLS_DC)
// @todo do we turn into endless conversion if the __toString object returns 'this' ??
// (and if it does: who cares? If the extension programmer is stupid, why do we have to suffer?)
-
+
// is the original parameter overwritten?
if (val == retval) zval_dtor(val);