|
34 | 34 | #include <ext/standard/info.h> |
35 | 35 | #include <Zend/zend_interfaces.h> |
36 | 36 | #include <ext/spl/spl_iterators.h> |
| 37 | + |
| 38 | +/* PHP array helpers */ |
| 39 | +#include "php_array_api.h" |
| 40 | + |
37 | 41 | /* Our Compatability header */ |
38 | 42 | #include "phongo_compat.h" |
39 | 43 |
|
@@ -75,8 +79,22 @@ PHP_METHOD(Query, __construct) |
75 | 79 | zval_to_bson(zfilter, PHONGO_BSON_NONE, &bfilter, NULL TSRMLS_CC); |
76 | 80 |
|
77 | 81 | if (zoptions) { |
| 82 | + if (php_array_exists(zoptions, "readConcern")) { |
| 83 | + zval *zread_concern = php_array_fetchc(zoptions, "readConcern"); |
| 84 | + |
| 85 | + if (Z_TYPE_P(zread_concern) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(zread_concern), php_phongo_readconcern_ce TSRMLS_CC)) { |
| 86 | + phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected \"readConcern\" option to be %s, %s given", php_phongo_readconcern_ce->name, zend_get_type_by_const(Z_TYPE_P(zread_concern))); |
| 87 | + bson_clear(&intern->query); |
| 88 | + return; |
| 89 | + } |
| 90 | + |
| 91 | + intern->read_concern = mongoc_read_concern_copy(phongo_read_concern_from_zval(zread_concern TSRMLS_CC)); |
| 92 | + php_array_unsetc(zoptions, "readConcern"); |
| 93 | + } |
| 94 | + |
78 | 95 | zval_to_bson(zoptions, PHONGO_BSON_NONE, &boptions, NULL TSRMLS_CC); |
79 | 96 | } |
| 97 | + |
80 | 98 | if (!phongo_query_init(intern, &bfilter, &boptions TSRMLS_CC)) { |
81 | 99 | bson_clear(&intern->query); |
82 | 100 | } |
@@ -117,6 +135,10 @@ static void php_phongo_query_free_object(void *object TSRMLS_DC) /* {{{ */ |
117 | 135 | bson_clear(&intern->query); |
118 | 136 | } |
119 | 137 |
|
| 138 | + if (intern->read_concern) { |
| 139 | + mongoc_read_concern_destroy(intern->read_concern); |
| 140 | + } |
| 141 | + |
120 | 142 | efree(intern); |
121 | 143 | } /* }}} */ |
122 | 144 |
|
|
0 commit comments