Skip to content
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

Fix for PHP 7.3 #190

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 8 additions & 0 deletions zmq.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,11 @@ php_zmq_context *php_zmq_context_get(zend_long io_threads, zend_bool is_persiste
le.type = php_zmq_context_list_entry();
le.ptr = context;

#if PHP_VERSION_ID < 70300
GC_REFCOUNT(&le) = 1;
#else
GC_SET_REFCOUNT(&le, 1);
#endif
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From UPGRADING.INTERNALS

  f. GC_REFCOUNT() is turned into inline function and can't be modified direcly.
     All reference-counting operations should be done through corresponding
     macros GC_SET_REFCOUNT(), GC_ADDREF() and GC_DELREF().

     GC_REFCOUNT(p)++ should be changed into GC_ADDREF(p),
     GC_REFCOUNT(p)-- into GC_DELREF(p),
     GC_REFCOUNT(p) = 1 into GC_SET_REFCOUNT(p, 1).


/* plist_key is not a persistent allocated key, thus we use str_update here */
if (zend_hash_str_update_mem(&EG(persistent_list), plist_key->val, plist_key->len, &le, sizeof(le)) == NULL) {
Expand Down Expand Up @@ -535,7 +539,11 @@ void php_zmq_socket_store(php_zmq_socket *zmq_sock_p, zend_long type, zend_strin
le.type = php_zmq_socket_list_entry();
le.ptr = zmq_sock_p;

#if PHP_VERSION_ID < 70300
GC_REFCOUNT(&le) = 1;
#else
GC_SET_REFCOUNT(&le, 1);
#endif

plist_key = php_zmq_socket_plist_key(type, persistent_id, use_shared_ctx);

Expand Down
4 changes: 2 additions & 2 deletions zmq_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ char *php_zmq_printable_func (zend_fcall_info *fci, zend_fcall_info_cache *fci_c
char *buffer = NULL;

if (fci->object) {
spprintf (&buffer, 0, "%s::%s", fci->object->ce->name->val, fci_cache->function_handler->common.function_name);
spprintf (&buffer, 0, "%s::%s", fci->object->ce->name->val, ZSTR_VAL(fci_cache->function_handler->common.function_name));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a zend_string since 7.0.

PHP 7.3 now nicely raise -Wformat warning about this

} else {
if (Z_TYPE (fci->function_name) == IS_OBJECT) {
spprintf (&buffer, 0, "%s", Z_OBJCE (fci->function_name)->name->val);
Expand All @@ -74,4 +74,4 @@ char *php_zmq_printable_func (zend_fcall_info *fci, zend_fcall_info_cache *fci_c
}
return buffer;
}
/* }}} */
/* }}} */
6 changes: 3 additions & 3 deletions zmq_pollset.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static
zend_string *s_create_key(zval *entry)
{
if (Z_TYPE_P(entry) == IS_RESOURCE) {
return strpprintf(0, "r:%ld", Z_RES_P(entry)->handle);
return strpprintf(0, "r:%d", Z_RES_P(entry)->handle);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-Wformat again, hadle is an int

}
else {
zend_string *hash = php_spl_object_hash(entry);
Expand Down Expand Up @@ -222,7 +222,7 @@ size_t php_zmq_pollset_num_items(php_zmq_pollset *set)
zend_string *php_zmq_pollset_add(php_zmq_pollset *set, zval *entry, int events, int *error)
{
zend_string *key;
size_t num_items, index;
size_t index;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-Wunused-but-set-variable

zmq_pollitem_t item;

*error = 0;
Expand All @@ -233,7 +233,7 @@ zend_string *php_zmq_pollset_add(php_zmq_pollset *set, zval *entry, int events,
return key;
}

num_items = php_zmq_pollset_num_items(set);
php_zmq_pollset_num_items(set);
memset(&item, 0, sizeof(zmq_pollitem_t));

if (Z_TYPE_P(entry) == IS_RESOURCE) {
Expand Down