@@ -82,14 +82,20 @@ static bool php_phongo_query_opts_append_document(bson_t* opts, const char* opts
82
82
return true;
83
83
} /* }}} */
84
84
85
- #define PHONGO_QUERY_OPT_BOOL (opt , zarr , key ) \
86
- if ((zarr) && php_array_existsc((zarr), (key))) { \
87
- if (!BSON_APPEND_BOOL(intern->opts, (opt), php_array_fetchc_bool((zarr), (key)))) { \
88
- phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error appending \"%s\" option", (opt)); \
89
- return false; \
90
- } \
85
+ #define PHONGO_QUERY_OPT_BOOL_EX (opt , zarr , key , deprecated ) \
86
+ if ((zarr) && php_array_existsc((zarr), (key))) { \
87
+ if ((deprecated)) { \
88
+ php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "The \"%s\" option is deprecated and will be removed in a future release", key); \
89
+ } \
90
+ if (!BSON_APPEND_BOOL(intern->opts, (opt), php_array_fetchc_bool((zarr), (key)))) { \
91
+ phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error appending \"%s\" option", (opt)); \
92
+ return false; \
93
+ } \
91
94
}
92
95
96
+ #define PHONGO_QUERY_OPT_BOOL (opt , zarr , key ) PHONGO_QUERY_OPT_BOOL_EX((opt), (zarr), (key), 0)
97
+ #define PHONGO_QUERY_OPT_BOOL_DEPRECATED (opt , zarr , key ) PHONGO_QUERY_OPT_BOOL_EX((opt), (zarr), (key), 1)
98
+
93
99
#define PHONGO_QUERY_OPT_DOCUMENT (opt , zarr , key ) \
94
100
if ((zarr) && php_array_existsc((zarr), (key))) { \
95
101
if (!php_phongo_query_opts_append_document(intern->opts, (opt), (zarr), (key) TSRMLS_CC)) { \
@@ -98,16 +104,22 @@ static bool php_phongo_query_opts_append_document(bson_t* opts, const char* opts
98
104
}
99
105
100
106
/* Note: handling of integer options will depend on SIZEOF_ZEND_LONG and we
101
- * are not converting strings to 64-bit integers for 32-bit platforms. */
102
-
103
- #define PHONGO_QUERY_OPT_INT64 (opt , zarr , key ) \
104
- if ((zarr) && php_array_existsc((zarr), (key))) { \
105
- if (!BSON_APPEND_INT64(intern->opts, (opt), php_array_fetchc_long((zarr), (key)))) { \
106
- phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error appending \"%s\" option", (opt)); \
107
- return false; \
108
- } \
107
+ * are not converting strings to 64-bit integers for 32-bit platforms. */
108
+
109
+ #define PHONGO_QUERY_OPT_INT64_EX (opt , zarr , key , deprecated ) \
110
+ if ((zarr) && php_array_existsc((zarr), (key))) { \
111
+ if ((deprecated)) { \
112
+ php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "The \"%s\" option is deprecated and will be removed in a future release", key); \
113
+ } \
114
+ if (!BSON_APPEND_INT64(intern->opts, (opt), php_array_fetchc_long((zarr), (key)))) { \
115
+ phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error appending \"%s\" option", (opt)); \
116
+ return false; \
117
+ } \
109
118
}
110
119
120
+ #define PHONGO_QUERY_OPT_INT64 (opt , zarr , key ) PHONGO_QUERY_OPT_INT64_EX((opt), (zarr), (key), 0)
121
+ #define PHONGO_QUERY_OPT_INT64_DEPRECATED (opt , zarr , key ) PHONGO_QUERY_OPT_INT64_EX((opt), (zarr), (key), 1)
122
+
111
123
#define PHONGO_QUERY_OPT_STRING (opt , zarr , key ) \
112
124
if ((zarr) && php_array_existsc((zarr), (key))) { \
113
125
if (!php_phongo_query_opts_append_string(intern->opts, (opt), (zarr), (key) TSRMLS_CC)) { \
@@ -277,8 +289,8 @@ static bool php_phongo_query_init(php_phongo_query_t* intern, zval* filter, zval
277
289
PHONGO_QUERY_OPT_BOOL ("exhaust" , options , "exhaust" );
278
290
PHONGO_QUERY_OPT_DOCUMENT ("max" , options , "max" )
279
291
else PHONGO_QUERY_OPT_DOCUMENT ("max" , modifiers , "$max" );
280
- PHONGO_QUERY_OPT_INT64 ("maxScan" , options , "maxScan" )
281
- else PHONGO_QUERY_OPT_INT64 ("maxScan" , modifiers , "$maxScan" );
292
+ PHONGO_QUERY_OPT_INT64_DEPRECATED ("maxScan" , options , "maxScan" )
293
+ else PHONGO_QUERY_OPT_INT64_DEPRECATED ("maxScan" , modifiers , "$maxScan" );
282
294
PHONGO_QUERY_OPT_INT64 ("maxTimeMS" , options , "maxTimeMS" )
283
295
else PHONGO_QUERY_OPT_INT64 ("maxTimeMS" , modifiers , "$maxTimeMS" );
284
296
PHONGO_QUERY_OPT_DOCUMENT ("min" , options , "min" )
@@ -293,8 +305,8 @@ static bool php_phongo_query_init(php_phongo_query_t* intern, zval* filter, zval
293
305
PHONGO_QUERY_OPT_INT64 ("skip" , options , "skip" );
294
306
PHONGO_QUERY_OPT_DOCUMENT ("sort" , options , "sort" )
295
307
else PHONGO_QUERY_OPT_DOCUMENT ("sort" , modifiers , "$orderby" );
296
- PHONGO_QUERY_OPT_BOOL ("snapshot" , options , "snapshot" )
297
- else PHONGO_QUERY_OPT_BOOL ("snapshot" , modifiers , "$snapshot" );
308
+ PHONGO_QUERY_OPT_BOOL_DEPRECATED ("snapshot" , options , "snapshot" )
309
+ else PHONGO_QUERY_OPT_BOOL_DEPRECATED ("snapshot" , modifiers , "$snapshot" );
298
310
PHONGO_QUERY_OPT_BOOL ("tailable" , options , "tailable" );
299
311
300
312
/* The "$explain" modifier should be converted to an "explain" option, which
0 commit comments