Commit 362ffbc4 authored by Ondrej Sury's avatar Ondrej Sury

New upstream version 1.2.9

parent 5a6f825a
......@@ -130,6 +130,7 @@
# define ADD_NEXT_INDEX_STRINGL(_zv, _value, _len) add_next_index_stringl(_zv, _value, _len, 1);
# define Z_PHPDATE_P(object) ((php_date_obj*)zend_object_store_get_object(object TSRMLS_CC))
# define Z_ISUNDEF(x) !x
# define ZVAL_UNDEF(x) do { (*x) = NULL; } while (0)
# define phongo_free_object_arg void
# define phongo_zpp_char_len int
# define ZEND_HASH_APPLY_PROTECTION(ht) true
......
......@@ -385,11 +385,7 @@ zend_bool phongo_writeconcernerror_init(zval *return_value, bson_t *bson TSRMLS_
if (!phongo_bson_to_zval(data, len, &intern->info)) {
zval_ptr_dtor(&intern->info);
#if PHP_VERSION_ID >= 70000
ZVAL_UNDEF(&intern->info);
#else
intern->info = NULL;
#endif
return false;
}
......@@ -426,11 +422,7 @@ zend_bool phongo_writeerror_init(zval *return_value, bson_t *bson TSRMLS_DC) /*
if (!phongo_bson_to_zval(data, len, &intern->info)) {
zval_ptr_dtor(&intern->info);
#if PHP_VERSION_ID >= 70000
ZVAL_UNDEF(&intern->info);
#else
intern->info = NULL;
#endif
return false;
}
......
......@@ -25,7 +25,7 @@
extern zend_module_entry mongodb_module_entry;
/* FIXME: Its annoying to bump version. Move into phongo_version.h.in */
#define PHP_MONGODB_VERSION "1.2.8"
#define PHP_MONGODB_VERSION "1.2.9"
#define PHP_MONGODB_STABILITY "stable"
#ifdef PHP_WIN32
......
......@@ -44,11 +44,7 @@ static void php_phongo_cursor_free_current(php_phongo_cursor_t *cursor) /* {{{ *
{
if (!Z_ISUNDEF(cursor->visitor_data.zchild)) {
zval_ptr_dtor(&cursor->visitor_data.zchild);
#if PHP_VERSION_ID >= 70000
ZVAL_UNDEF(&cursor->visitor_data.zchild);
#else
cursor->visitor_data.zchild = NULL;
#endif
}
} /* }}} */
......
......@@ -1019,7 +1019,7 @@ void object_to_bson(zval *object, php_phongo_bson_flags_t flags, const char *key
zval *obj_data = NULL;
#endif
bson_t child;
HashTable *tmp_ht;
#if PHP_VERSION_ID >= 70000
zend_call_method_with_0_params(object, NULL, NULL, BSON_SERIALIZE_FUNC_NAME, &obj_data);
#else
......@@ -1027,7 +1027,8 @@ void object_to_bson(zval *object, php_phongo_bson_flags_t flags, const char *key
#endif
if (Z_ISUNDEF(obj_data)) {
/* zend_call_method() failed */
/* zend_call_method() failed or bsonSerialize() threw an
* exception. Either way, there is nothing else to do. */
return;
}
......@@ -1060,16 +1061,6 @@ void object_to_bson(zval *object, php_phongo_bson_flags_t flags, const char *key
return;
}
#if PHP_VERSION_ID >= 70000
tmp_ht = HASH_OF(&obj_data);
#else
tmp_ht = HASH_OF(obj_data);
#endif
if (tmp_ht && ZEND_HASH_APPLY_PROTECTION(tmp_ht)) {
ZEND_HASH_INC_APPLY_COUNT(tmp_ht);
}
/* Persistable objects must always be serialized as BSON documents;
* otherwise, infer based on bsonSerialize()'s return value. */
#if PHP_VERSION_ID >= 70000
......@@ -1101,9 +1092,6 @@ void object_to_bson(zval *object, php_phongo_bson_flags_t flags, const char *key
bson_append_array_end(bson, &child);
}
if (tmp_ht && ZEND_HASH_APPLY_PROTECTION(tmp_ht)) {
ZEND_HASH_DEC_APPLY_COUNT(tmp_ht);
}
zval_ptr_dtor(&obj_data);
return;
}
......@@ -1176,20 +1164,10 @@ void object_to_bson(zval *object, php_phongo_bson_flags_t flags, const char *key
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "Unexpected %s instance: %s", ZSTR_VAL(php_phongo_type_ce->name), ZSTR_VAL(Z_OBJCE_P(object)->name));
return;
} else {
HashTable *tmp_ht = HASH_OF(object);
if (tmp_ht && ZEND_HASH_APPLY_PROTECTION(tmp_ht)) {
ZEND_HASH_INC_APPLY_COUNT(tmp_ht);
}
mongoc_log(MONGOC_LOG_LEVEL_TRACE, MONGOC_LOG_DOMAIN, "encoding document");
bson_append_document_begin(bson, key, key_len, &child);
phongo_zval_to_bson(object, flags, &child, NULL TSRMLS_CC);
bson_append_document_end(bson, &child);
if (tmp_ht && ZEND_HASH_APPLY_PROTECTION(tmp_ht)) {
ZEND_HASH_DEC_APPLY_COUNT(tmp_ht);
}
}
}
......@@ -1238,6 +1216,11 @@ try_again:
bson_t child;
HashTable *tmp_ht = HASH_OF(entry);
if (tmp_ht && ZEND_HASH_GET_APPLY_COUNT(tmp_ht) > 0) {
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "Detected recursion for fieldname \"%s\"", key);
break;
}
if (tmp_ht && ZEND_HASH_APPLY_PROTECTION(tmp_ht)) {
ZEND_HASH_INC_APPLY_COUNT(tmp_ht);
}
......@@ -1252,9 +1235,25 @@ try_again:
break;
}
/* break intentionally omitted */
case IS_OBJECT:
case IS_OBJECT: {
HashTable *tmp_ht = HASH_OF(entry);
if (tmp_ht && ZEND_HASH_GET_APPLY_COUNT(tmp_ht) > 0) {
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "Detected recursion for fieldname \"%s\"", key);
break;
}
if (tmp_ht && ZEND_HASH_APPLY_PROTECTION(tmp_ht)) {
ZEND_HASH_INC_APPLY_COUNT(tmp_ht);
}
object_to_bson(entry, flags, key, key_len, bson TSRMLS_CC);
if (tmp_ht && ZEND_HASH_APPLY_PROTECTION(tmp_ht)) {
ZEND_HASH_DEC_APPLY_COUNT(tmp_ht);
}
break;
}
#if PHP_VERSION_ID >= 70000
case IS_INDIRECT:
......@@ -1285,6 +1284,8 @@ void phongo_zval_to_bson(zval *data, php_phongo_bson_flags_t flags, bson_t *bson
* properties, we'll need to filter them out later. */
bool ht_data_from_properties = false;
ZVAL_UNDEF(&obj_data);
switch(Z_TYPE_P(data)) {
case IS_OBJECT:
if (instanceof_function(Z_OBJCE_P(data), php_phongo_serializable_ce TSRMLS_CC)) {
......@@ -1295,8 +1296,9 @@ void phongo_zval_to_bson(zval *data, php_phongo_bson_flags_t flags, bson_t *bson
#endif
if (Z_ISUNDEF(obj_data)) {
/* zend_call_method() failed */
break;
/* zend_call_method() failed or bsonSerialize() threw an
* exception. Either way, there is nothing else to do. */
return;
}
#if PHP_VERSION_ID >= 70000
......@@ -1324,7 +1326,7 @@ void phongo_zval_to_bson(zval *data, php_phongo_bson_flags_t flags, bson_t *bson
)
);
break;
goto cleanup;
}
#if PHP_VERSION_ID >= 70000
......@@ -1349,7 +1351,7 @@ void phongo_zval_to_bson(zval *data, php_phongo_bson_flags_t flags, bson_t *bson
if (instanceof_function(Z_OBJCE_P(data), php_phongo_type_ce TSRMLS_CC)) {
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "%s instance %s cannot be serialized as a root element", ZSTR_VAL(php_phongo_type_ce->name), ZSTR_VAL(Z_OBJCE_P(data)->name));
break;
return;
}
ht_data = Z_OBJ_HT_P(data)->get_properties(data TSRMLS_CC);
......@@ -1364,19 +1366,6 @@ void phongo_zval_to_bson(zval *data, php_phongo_bson_flags_t flags, bson_t *bson
return;
}