From 02b4c4563ebcacdb45b23af5b572aade329c86c9 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 2 Sep 2020 11:24:30 +0200 Subject: [PATCH] fix for 8.0.0beta3 --- ext/maxminddb.c | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/ext/maxminddb.c b/ext/maxminddb.c index 4947492..e2b46a4 100644 --- a/ext/maxminddb.c +++ b/ext/maxminddb.c @@ -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 */ @@ -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) { @@ -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); @@ -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); @@ -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); @@ -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); }