77
77
#define PHONGO_STREAM_BUFFER_SIZE 4096
78
78
79
79
ZEND_DECLARE_MODULE_GLOBALS (mongodb )
80
+ #if PHP_VERSION_ID >= 70000
81
+ #if defined(ZTS ) && defined(COMPILE_DL_MONGODB )
82
+ ZEND_TSRMLS_CACHE_DEFINE ();
83
+ #endif
84
+ #endif
80
85
81
86
/* {{{ phongo_std_object_handlers */
82
87
zend_object_handlers phongo_std_object_handlers ;
@@ -1747,7 +1752,9 @@ static bool php_phongo_apply_wc_options_to_client(mongoc_client_t *client, bson_
1747
1752
1748
1753
static mongoc_client_t * php_phongo_make_mongo_client (const mongoc_uri_t * uri , zval * driverOptions TSRMLS_DC ) /* {{{ */
1749
1754
{
1750
- #ifdef PHONGO_TODO_INI
1755
+ #if PHP_VERSION_ID >= 70000
1756
+ zval * tmp ;
1757
+ #else
1751
1758
zval * * tmp ;
1752
1759
#endif
1753
1760
php_stream_context * ctx = NULL ;
@@ -1756,12 +1763,15 @@ static mongoc_client_t *php_phongo_make_mongo_client(const mongoc_uri_t *uri, zv
1756
1763
1757
1764
ENTRY ;
1758
1765
1759
- #ifndef PHONGO_TODO_INI
1760
- (void )driverOptions ;
1761
- #endif
1762
-
1763
-
1764
- #ifdef PHONGO_TODO_INI
1766
+ #if PHP_VERSION_ID >= 70000
1767
+ if (driverOptions && (tmp = zend_hash_str_find (Z_ARRVAL_P (driverOptions ), "debug" , sizeof ("debug" )- 1 )) != NULL ) {
1768
+ zend_string * key = zend_string_init (PHONGO_DEBUG_INI , sizeof (PHONGO_DEBUG_INI )- 1 , 0 );
1769
+ zend_string * value_str = zval_get_string (tmp );
1770
+ zend_alter_ini_entry_ex (key , value_str , PHP_INI_USER , PHP_INI_STAGE_RUNTIME , 0 );
1771
+ zend_string_release (key );
1772
+ zend_string_release (value_str );
1773
+ }
1774
+ #else
1765
1775
if (driverOptions && zend_hash_find (Z_ARRVAL_P (driverOptions ), "debug" , strlen ("debug" ) + 1 , (void * * )& tmp ) == SUCCESS ) {
1766
1776
convert_to_string (* tmp );
1767
1777
@@ -2221,11 +2231,13 @@ ZEND_INI_MH(OnUpdateDebug)
2221
2231
2222
2232
2223
2233
/* {{{ INI entries */
2224
- #ifdef PHONGO_TODO_INI
2225
2234
PHP_INI_BEGIN ()
2235
+ #if PHP_VERSION_ID >= 70000
2236
+ STD_PHP_INI_ENTRY (PHONGO_DEBUG_INI , PHONGO_DEBUG_INI_DEFAULT , PHP_INI_ALL , OnUpdateDebug , debug , zend_mongodb_globals , mongodb_globals )
2237
+ #else
2226
2238
{ 0 , PHP_INI_ALL , (char * )PHONGO_DEBUG_INI , sizeof (PHONGO_DEBUG_INI ), OnUpdateDebug , (void * ) XtOffsetOf (zend_mongodb_globals , debug ), (void * ) & mglo , NULL , (char * )PHONGO_DEBUG_INI_DEFAULT , sizeof (PHONGO_DEBUG_INI_DEFAULT )- 1 , NULL , 0 , 0 , 0 , NULL },
2227
- PHP_INI_END ()
2228
2239
#endif
2240
+ PHP_INI_END ()
2229
2241
/* }}} */
2230
2242
2231
2243
/* {{{ PHP_GINIT_FUNCTION */
@@ -2237,6 +2249,11 @@ PHP_GINIT_FUNCTION(mongodb)
2237
2249
php_phongo_realloc ,
2238
2250
php_phongo_free ,
2239
2251
};
2252
+ #if PHP_VERSION_ID >= 70000
2253
+ #if defined(COMPILE_DL_MONGODB ) && defined(ZTS )
2254
+ ZEND_TSRMLS_CACHE_UPDATE ();
2255
+ #endif
2256
+ #endif
2240
2257
mongodb_globals -> debug_fd = NULL ;
2241
2258
mongodb_globals -> bsonMemVTable = bsonMemVTable ;
2242
2259
@@ -2249,9 +2266,7 @@ PHP_MINIT_FUNCTION(mongodb)
2249
2266
(void )type ; /* We don't care if we are loaded via dl() or extension= */
2250
2267
2251
2268
2252
- #ifdef PHONGO_TODO_INI
2253
2269
REGISTER_INI_ENTRIES ();
2254
- #endif
2255
2270
2256
2271
/* Initialize libmongoc */
2257
2272
mongoc_init ();
@@ -2328,9 +2343,7 @@ PHP_MSHUTDOWN_FUNCTION(mongodb)
2328
2343
/* Cleanup after libmongoc */
2329
2344
mongoc_cleanup ();
2330
2345
2331
- #ifdef PHONGO_TODO_INI
2332
2346
UNREGISTER_INI_ENTRIES ();
2333
- #endif
2334
2347
2335
2348
return SUCCESS ;
2336
2349
}
0 commit comments