Skip to content

php7 + apache2 fix #25

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 4 commits into
base: master
Choose a base branch
from
Open
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
25 changes: 25 additions & 0 deletions wr_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Etienne Kneuss <[email protected]> |
| Fix for PHP7+Apache2: CommerceByte Consulting <[email protected]> |
+----------------------------------------------------------------------+
*/

Expand All @@ -38,9 +39,25 @@ void wr_store_init() /* {{{ */
WR_G(store) = store;
} /* }}} */

/* See comment in wr_store_destroy */
int wr_store_dtor_restore(zval *val,int arg_num, va_list arg_list, zend_hash_key *key)
{
zend_object_dtor_obj_t *dtor = (zend_object_dtor_obj_t*) val;

((zend_object_handlers *) key->h)->dtor_obj = *dtor;
return ZEND_HASH_APPLY_REMOVE;
}

void wr_store_destroy() /* {{{ */
{
wr_store *store = WR_G(store);

/*
[email protected] -
Explicitly restore the dtor handlers
Not doing so causes a disaster in PHP7 + Apache2 lib environment
*/
zend_hash_apply_with_arguments(&store->old_dtors, wr_store_dtor_restore, 0);

zend_hash_destroy(&store->old_dtors);
zend_hash_destroy(&store->objs);
Expand All @@ -50,11 +67,19 @@ void wr_store_destroy() /* {{{ */
WR_G(store) = NULL;
} /* }}} */



/* This function is invoked whenever an object tracked by a weak ref/map is
* destroyed */
void wr_store_tracked_object_dtor(zend_object *ref_obj) /* {{{ */
{
wr_store *store = WR_G(store);

if (!store) {
/* Sanity check, should never get here as long as wr_store_dtor_restore() is engaged */
return;
}

zend_object_dtor_obj_t orig_dtor = zend_hash_index_find_ptr(&store->old_dtors, (ulong)ref_obj->handlers);
ulong handle_key = ref_obj->handle;
wr_ref_list *list_entry;
Expand Down