Skip to content

Commit a6e7202

Browse files
committed
PHPC-761: Remove BSON_NAMESPACE constant
1 parent 1a3fc38 commit a6e7202

17 files changed

+18
-32
lines changed

php_bson.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@
2626
/* PHP Core stuff */
2727
#include <php.h>
2828

29-
/* Check if we are part of pecl/mongodb or standalone (pecl/bson) */
30-
#ifdef HAVE_MONGOC
31-
#define BSON_NAMESPACE "MongoDB\\BSON"
32-
#else
33-
#define BSON_NAMESPACE "BSON"
34-
#endif
35-
3629
#define BSON_UNSERIALIZE_FUNC_NAME "bsonUnserialize"
3730
#define BSON_SERIALIZE_FUNC_NAME "bsonSerialize"
3831

php_phongo.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2507,7 +2507,6 @@ PHP_MINIT_FUNCTION(mongodb)
25072507

25082508
REGISTER_STRING_CONSTANT("MONGODB_VERSION", (char *)MONGODB_VERSION_S, CONST_CS | CONST_PERSISTENT);
25092509
REGISTER_STRING_CONSTANT("MONGODB_STABILITY", (char *)MONGODB_STABILITY_S, CONST_CS | CONST_PERSISTENT);
2510-
REGISTER_STRING_CONSTANT("BSON_NAMESPACE", (char *)BSON_NAMESPACE, CONST_CS | CONST_PERSISTENT);
25112510

25122511
return SUCCESS;
25132512
}
@@ -2586,10 +2585,10 @@ ZEND_BEGIN_ARG_INFO_EX(ai_bson_fromJSON, 0, 0, 1)
25862585
ZEND_END_ARG_INFO();
25872586

25882587
const zend_function_entry mongodb_functions[] = {
2589-
ZEND_NS_FE(BSON_NAMESPACE, fromPHP, ai_bson_fromPHP)
2590-
ZEND_NS_FE(BSON_NAMESPACE, toPHP, ai_bson_toPHP)
2591-
ZEND_NS_FE(BSON_NAMESPACE, toJSON, ai_bson_toJSON)
2592-
ZEND_NS_FE(BSON_NAMESPACE, fromJSON, ai_bson_fromJSON)
2588+
ZEND_NS_FE("MongoDB\\BSON", fromPHP, ai_bson_fromPHP)
2589+
ZEND_NS_FE("MongoDB\\BSON", toPHP, ai_bson_toPHP)
2590+
ZEND_NS_FE("MongoDB\\BSON", toJSON, ai_bson_toJSON)
2591+
ZEND_NS_FE("MongoDB\\BSON", fromJSON, ai_bson_fromJSON)
25932592
PHP_FE_END
25942593
};
25952594
/* }}} */

src/BSON/Binary.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ PHP_MINIT_FUNCTION(Binary)
312312
zend_class_entry ce;
313313
(void)type;(void)module_number;
314314

315-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Binary", php_phongo_binary_me);
315+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Binary", php_phongo_binary_me);
316316
php_phongo_binary_ce = zend_register_internal_class(&ce TSRMLS_CC);
317317
php_phongo_binary_ce->create_object = php_phongo_binary_create_object;
318318
PHONGO_CE_FINAL(php_phongo_binary_ce);

src/BSON/Decimal128.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ PHP_MINIT_FUNCTION(Decimal128)
267267
zend_class_entry ce;
268268
(void)type;(void)module_number;
269269

270-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Decimal128", php_phongo_decimal128_me);
270+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Decimal128", php_phongo_decimal128_me);
271271
php_phongo_decimal128_ce = zend_register_internal_class(&ce TSRMLS_CC);
272272
php_phongo_decimal128_ce->create_object = php_phongo_decimal128_create_object;
273273
PHONGO_CE_FINAL(php_phongo_decimal128_ce);

src/BSON/Javascript.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ PHP_MINIT_FUNCTION(Javascript)
370370
(void)type;(void)module_number;
371371

372372

373-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Javascript", php_phongo_javascript_me);
373+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Javascript", php_phongo_javascript_me);
374374
php_phongo_javascript_ce = zend_register_internal_class(&ce TSRMLS_CC);
375375
php_phongo_javascript_ce->create_object = php_phongo_javascript_create_object;
376376
PHONGO_CE_FINAL(php_phongo_javascript_ce);

src/BSON/MaxKey.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ PHP_MINIT_FUNCTION(MaxKey)
129129
(void)type;(void)module_number;
130130

131131

132-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "MaxKey", php_phongo_maxkey_me);
132+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "MaxKey", php_phongo_maxkey_me);
133133
php_phongo_maxkey_ce = zend_register_internal_class(&ce TSRMLS_CC);
134134
php_phongo_maxkey_ce->create_object = php_phongo_maxkey_create_object;
135135
PHONGO_CE_FINAL(php_phongo_maxkey_ce);

src/BSON/MinKey.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ PHP_MINIT_FUNCTION(MinKey)
130130
(void)type;(void)module_number;
131131

132132

133-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "MinKey", php_phongo_minkey_me);
133+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "MinKey", php_phongo_minkey_me);
134134
php_phongo_minkey_ce = zend_register_internal_class(&ce TSRMLS_CC);
135135
php_phongo_minkey_ce->create_object = php_phongo_minkey_create_object;
136136
PHONGO_CE_FINAL(php_phongo_minkey_ce);

src/BSON/ObjectID.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ PHP_MINIT_FUNCTION(ObjectID)
301301
zend_class_entry ce;
302302
(void)type;(void)module_number;
303303

304-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "ObjectID", php_phongo_objectid_me);
304+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "ObjectID", php_phongo_objectid_me);
305305
php_phongo_objectid_ce = zend_register_internal_class(&ce TSRMLS_CC);
306306
php_phongo_objectid_ce->create_object = php_phongo_objectid_create_object;
307307
PHONGO_CE_FINAL(php_phongo_objectid_ce);

src/BSON/Persistable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ PHP_MINIT_FUNCTION(Persistable)
6363
zend_class_entry ce;
6464
(void)type;(void)module_number;
6565

66-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Persistable", php_phongo_persistable_me);
66+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Persistable", php_phongo_persistable_me);
6767
php_phongo_persistable_ce = zend_register_internal_interface(&ce TSRMLS_CC);
6868
zend_class_implements(php_phongo_persistable_ce TSRMLS_CC, 2, php_phongo_unserializable_ce, php_phongo_serializable_ce);
6969

src/BSON/Regex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ PHP_MINIT_FUNCTION(Regex)
352352
zend_class_entry ce;
353353
(void)type;(void)module_number;
354354

355-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Regex", php_phongo_regex_me);
355+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Regex", php_phongo_regex_me);
356356
php_phongo_regex_ce = zend_register_internal_class(&ce TSRMLS_CC);
357357
php_phongo_regex_ce->create_object = php_phongo_regex_create_object;
358358
PHONGO_CE_FINAL(php_phongo_regex_ce);

src/BSON/Serializable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ PHP_MINIT_FUNCTION(Serializable)
6666
zend_class_entry ce;
6767
(void)type;(void)module_number;
6868

69-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Serializable", php_phongo_serializable_me);
69+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Serializable", php_phongo_serializable_me);
7070
php_phongo_serializable_ce = zend_register_internal_interface(&ce TSRMLS_CC);
7171
zend_class_implements(php_phongo_serializable_ce TSRMLS_CC, 1, php_phongo_type_ce);
7272

src/BSON/Timestamp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ PHP_MINIT_FUNCTION(Timestamp)
303303
zend_class_entry ce;
304304
(void)type;(void)module_number;
305305

306-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Timestamp", php_phongo_timestamp_me);
306+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Timestamp", php_phongo_timestamp_me);
307307
php_phongo_timestamp_ce = zend_register_internal_class(&ce TSRMLS_CC);
308308
php_phongo_timestamp_ce->create_object = php_phongo_timestamp_create_object;
309309
PHONGO_CE_FINAL(php_phongo_timestamp_ce);

src/BSON/Type.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ PHP_MINIT_FUNCTION(Type)
6363
zend_class_entry ce;
6464
(void)type;(void)module_number;
6565

66-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Type", php_phongo_type_me);
66+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Type", php_phongo_type_me);
6767
php_phongo_type_ce = zend_register_internal_interface(&ce TSRMLS_CC);
6868

6969
return SUCCESS;

src/BSON/UTCDateTime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ PHP_MINIT_FUNCTION(UTCDateTime)
421421
zend_class_entry ce;
422422
(void)type;(void)module_number;
423423

424-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "UTCDateTime", php_phongo_utcdatetime_me);
424+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "UTCDateTime", php_phongo_utcdatetime_me);
425425
php_phongo_utcdatetime_ce = zend_register_internal_class(&ce TSRMLS_CC);
426426
php_phongo_utcdatetime_ce->create_object = php_phongo_utcdatetime_create_object;
427427
PHONGO_CE_FINAL(php_phongo_utcdatetime_ce);

src/BSON/Unserializable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ PHP_MINIT_FUNCTION(Unserializable)
6767
zend_class_entry ce;
6868
(void)type;(void)module_number;
6969

70-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Unserializable", php_phongo_unserializable_me);
70+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Unserializable", php_phongo_unserializable_me);
7171
php_phongo_unserializable_ce = zend_register_internal_interface(&ce TSRMLS_CC);
7272

7373
return SUCCESS;

src/bson.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1552,7 +1552,7 @@ static void apply_classname_to_state(const char *classname, int classname_len, p
15521552
} else if (!PHONGO_IS_CLASS_INSTANTIATABLE(found_ce)) {
15531553
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Class %s is not instantiatable", classname);
15541554
} else if (!instanceof_function(found_ce, php_phongo_unserializable_ce TSRMLS_CC)) {
1555-
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Class %s does not implement %s\\Unserializable", classname, BSON_NAMESPACE);
1555+
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Class %s does not implement %s", classname, ZSTR_VAL(php_phongo_unserializable_ce->name));
15561556
} else {
15571557
*type = PHONGO_TYPEMAP_CLASS;
15581558
*type_ce = found_ce;

tests/utils/basic.inc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,3 @@ $consts = array(
3636
"NS" => DATABASE_NAME . "." . COLLECTION_NAME,
3737
);
3838
def($consts);
39-
40-
/* If its not defined, set it to what the MongoDB exts define it, since this is mostly used for pecl/bson testing */
41-
if (!defined("BSON_NAMESPACE")) {
42-
define("BSON_NAMESPACE", "MongoDB\\BSON");
43-
}
44-

0 commit comments

Comments
 (0)