Skip to content

Commit

Permalink
fix for 8.0.0beta3
Browse files Browse the repository at this point in the history
  • Loading branch information
remicollet committed Sep 2, 2020
1 parent 942553d commit 02b4c45
Showing 1 changed file with 20 additions and 26 deletions.
46 changes: 20 additions & 26 deletions ext/maxminddb.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,21 @@ typedef size_t strsize_t;
typedef zend_object free_obj_t;

/* For PHP 8 compatibility */
#ifndef TSRMLS_C
#if PHP_VERSION_ID < 80000

#define PROP_OBJ(zv) (zv)

#else

#define PROP_OBJ(zv) Z_OBJ_P(zv)

#define TSRMLS_C
#endif
#ifndef TSRMLS_CC
#define TSRMLS_CC
#endif
#ifndef TSRMLS_DC
#define TSRMLS_DC
#endif
#ifndef ZEND_ACC_CTOR

#define ZEND_ACC_CTOR 0

/* End PHP 8 compatibility */
#endif

/* IS_MIXED was added in 2020 */
Expand Down Expand Up @@ -334,23 +338,13 @@ PHP_METHOD(MaxMind_Db_Reader, metadata) {
return;
}
MMDB_free_entry_data_list(entry_data_list);
#if PHP_VERSION_ID >= 80000
zend_call_method_with_1_params(Z_OBJ_P(return_value),
zend_call_method_with_1_params(PROP_OBJ(return_value),
metadata_ce,
&metadata_ce->constructor,
ZEND_CONSTRUCTOR_FUNC_NAME,
NULL,
&metadata_array);
zval_ptr_dtor(&metadata_array);
#else
zend_call_method_with_1_params(return_value,
metadata_ce,
&metadata_ce->constructor,
ZEND_CONSTRUCTOR_FUNC_NAME,
NULL,
&metadata_array);
zval_ptr_dtor(&metadata_array);
#endif
}

PHP_METHOD(MaxMind_Db_Reader, close) {
Expand Down Expand Up @@ -607,7 +601,7 @@ PHP_METHOD(MaxMind_Db_Reader_Metadata, __construct) {
"binary_format_major_version",
sizeof("binary_format_major_version") - 1))) {
zend_update_property(metadata_ce,
object,
PROP_OBJ(object),
"binaryFormatMajorVersion",
sizeof("binaryFormatMajorVersion") - 1,
tmp);
Expand All @@ -617,7 +611,7 @@ PHP_METHOD(MaxMind_Db_Reader_Metadata, __construct) {
"binary_format_minor_version",
sizeof("binary_format_minor_version") - 1))) {
zend_update_property(metadata_ce,
object,
PROP_OBJ(object),
"binaryFormatMinorVersion",
sizeof("binaryFormatMinorVersion") - 1,
tmp);
Expand All @@ -627,14 +621,14 @@ PHP_METHOD(MaxMind_Db_Reader_Metadata, __construct) {
"build_epoch",
sizeof("build_epoch") - 1))) {
zend_update_property(
metadata_ce, object, "buildEpoch", sizeof("buildEpoch") - 1, tmp);
metadata_ce, PROP_OBJ(object), "buildEpoch", sizeof("buildEpoch") - 1, tmp);
}

if ((tmp = zend_hash_str_find(HASH_OF(metadata_array),
"database_type",
sizeof("database_type") - 1))) {
zend_update_property(metadata_ce,
object,
PROP_OBJ(object),
"databaseType",
sizeof("databaseType") - 1,
tmp);
Expand All @@ -644,27 +638,27 @@ PHP_METHOD(MaxMind_Db_Reader_Metadata, __construct) {
"description",
sizeof("description") - 1))) {
zend_update_property(
metadata_ce, object, "description", sizeof("description") - 1, tmp);
metadata_ce, PROP_OBJ(object), "description", sizeof("description") - 1, tmp);
}

if ((tmp = zend_hash_str_find(HASH_OF(metadata_array),
"ip_version",
sizeof("ip_version") - 1))) {
zend_update_property(
metadata_ce, object, "ipVersion", sizeof("ipVersion") - 1, tmp);
metadata_ce, PROP_OBJ(object), "ipVersion", sizeof("ipVersion") - 1, tmp);
}

if ((tmp = zend_hash_str_find(
HASH_OF(metadata_array), "languages", sizeof("languages") - 1))) {
zend_update_property(
metadata_ce, object, "languages", sizeof("languages") - 1, tmp);
metadata_ce, PROP_OBJ(object), "languages", sizeof("languages") - 1, tmp);
}

if ((tmp = zend_hash_str_find(HASH_OF(metadata_array),
"record_size",
sizeof("record_size") - 1))) {
zend_update_property(
metadata_ce, object, "recordSize", sizeof("recordSize") - 1, tmp);
metadata_ce, PROP_OBJ(object), "recordSize", sizeof("recordSize") - 1, tmp);
if (Z_TYPE_P(tmp) == IS_LONG) {
record_size = Z_LVAL_P(tmp);
}
Expand Down

0 comments on commit 02b4c45

Please sign in to comment.