Skip to content

Commit 4958e36

Browse files
committed
Add compat macro for Z_PARAM_ARRAY_OR_OBJECT
1 parent 0c468b6 commit 4958e36

File tree

6 files changed

+18
-8
lines changed

6 files changed

+18
-8
lines changed

src/BSON/functions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ PHP_FUNCTION(MongoDB_BSON_fromPHP)
3636
bson_t* bson;
3737

3838
PHONGO_PARSE_PARAMETERS_START(1, 1)
39-
Z_PARAM_ARRAY_OR_OBJECT(data)
39+
PHONGO_PARAM_ARRAY_OR_OBJECT(data)
4040
PHONGO_PARSE_PARAMETERS_END();
4141

4242
bson = bson_new();

src/MongoDB/BulkWrite.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ static PHP_METHOD(BulkWrite, insert)
388388
intern = Z_BULKWRITE_OBJ_P(getThis());
389389

390390
PHONGO_PARSE_PARAMETERS_START(1, 1)
391-
Z_PARAM_ARRAY_OR_OBJECT(zdocument)
391+
PHONGO_PARAM_ARRAY_OR_OBJECT(zdocument)
392392
PHONGO_PARSE_PARAMETERS_END();
393393

394394
bson_flags |= PHONGO_BSON_RETURN_ID;
@@ -431,8 +431,8 @@ static PHP_METHOD(BulkWrite, update)
431431
intern = Z_BULKWRITE_OBJ_P(getThis());
432432

433433
PHONGO_PARSE_PARAMETERS_START(2, 3)
434-
Z_PARAM_ARRAY_OR_OBJECT(zquery)
435-
Z_PARAM_ARRAY_OR_OBJECT(zupdate)
434+
PHONGO_PARAM_ARRAY_OR_OBJECT(zquery)
435+
PHONGO_PARAM_ARRAY_OR_OBJECT(zupdate)
436436
Z_PARAM_OPTIONAL
437437
Z_PARAM_ARRAY_OR_NULL(zoptions)
438438
PHONGO_PARSE_PARAMETERS_END();
@@ -497,7 +497,7 @@ static PHP_METHOD(BulkWrite, delete)
497497
intern = Z_BULKWRITE_OBJ_P(getThis());
498498

499499
PHONGO_PARSE_PARAMETERS_START(1, 2)
500-
Z_PARAM_ARRAY_OR_OBJECT(zquery)
500+
PHONGO_PARAM_ARRAY_OR_OBJECT(zquery)
501501
Z_PARAM_OPTIONAL
502502
Z_PARAM_ARRAY_OR_NULL(zoptions)
503503
PHONGO_PARSE_PARAMETERS_END();

src/MongoDB/Command.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static PHP_METHOD(Command, __construct)
107107
intern = Z_COMMAND_OBJ_P(getThis());
108108

109109
PHONGO_PARSE_PARAMETERS_START(1, 2)
110-
Z_PARAM_ARRAY_OR_OBJECT(document)
110+
PHONGO_PARAM_ARRAY_OR_OBJECT(document)
111111
Z_PARAM_OPTIONAL
112112
Z_PARAM_ARRAY_OR_NULL(options)
113113
PHONGO_PARSE_PARAMETERS_END();

src/MongoDB/Query.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ static PHP_METHOD(Query, __construct)
398398
intern = Z_QUERY_OBJ_P(getThis());
399399

400400
PHONGO_PARSE_PARAMETERS_START(1, 2)
401-
Z_PARAM_ARRAY_OR_OBJECT(filter)
401+
PHONGO_PARAM_ARRAY_OR_OBJECT(filter)
402402
Z_PARAM_OPTIONAL
403403
Z_PARAM_ARRAY_OR_NULL(options)
404404
PHONGO_PARSE_PARAMETERS_END();

src/MongoDB/Session.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static PHP_METHOD(Session, advanceClusterTime)
171171
SESSION_CHECK_LIVELINESS(intern, "advanceClusterTime")
172172

173173
PHONGO_PARSE_PARAMETERS_START(1, 1)
174-
Z_PARAM_ARRAY_OR_OBJECT(zcluster_time)
174+
PHONGO_PARAM_ARRAY_OR_OBJECT(zcluster_time)
175175
PHONGO_PARSE_PARAMETERS_END();
176176

177177
php_phongo_zval_to_bson(zcluster_time, PHONGO_BSON_NONE, &cluster_time, NULL);

src/phongo_compat.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,16 @@ static inline zend_bool zend_ini_parse_bool(zend_string* str)
254254
Z_PARAM_ZVAL_EX(dest, 1, 0)
255255
#endif
256256

257+
/* Z_PARAM_ARRAY_OR_OBJECT requires 3 arguments in PHP < 7.3.
258+
* See: https://github.com/php/php-src/commit/a595b0f75bf8bc0d3da8ca5cb03f8b1a694d26b2 */
259+
#if PHP_VERSION_ID < 70300
260+
#define PHONGO_PARAM_ARRAY_OR_OBJECT(dest) \
261+
Z_PARAM_ARRAY_OR_OBJECT(dest, 0, 0)
262+
#else
263+
#define PHONGO_PARAM_ARRAY_OR_OBJECT(dest) \
264+
Z_PARAM_ARRAY_OR_OBJECT(dest)
265+
#endif
266+
257267
/* Per https://wiki.php.net/rfc/internal_method_return_types, "Non-final
258268
* internal method return types - when possible - are declared tentatively in
259269
* PHP 8.1, and they will become enforced in PHP 9.0." This can be revisited

0 commit comments

Comments
 (0)