Skip to content

Commit c367819

Browse files
committed
Merge pull request #126
2 parents 5d16172 + b63c10f commit c367819

28 files changed

+383
-11
lines changed

src/BSON/Binary.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ static zend_function_entry php_phongo_binary_me[] = {
123123
PHP_ME(Binary, __construct, ai_Binary___construct, ZEND_ACC_PUBLIC)
124124
PHP_ME(Binary, getData, ai_Binary_getData, ZEND_ACC_PUBLIC)
125125
PHP_ME(Binary, getType, ai_Binary_getType, ZEND_ACC_PUBLIC)
126+
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
126127
PHP_FE_END
127128
};
128129

@@ -182,8 +183,9 @@ PHP_MINIT_FUNCTION(Binary)
182183
(void)type;(void)module_number;
183184

184185
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Binary", php_phongo_binary_me);
185-
ce.create_object = php_phongo_binary_create_object;
186186
php_phongo_binary_ce = zend_register_internal_class(&ce TSRMLS_CC);
187+
php_phongo_binary_ce->create_object = php_phongo_binary_create_object;
188+
PHONGO_CE_INIT(php_phongo_binary_ce);
187189

188190
zend_class_implements(php_phongo_binary_ce TSRMLS_CC, 1, php_phongo_type_ce);
189191

src/BSON/Javascript.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ ZEND_END_ARG_INFO();
8585

8686
static zend_function_entry php_phongo_javascript_me[] = {
8787
PHP_ME(Javascript, __construct, ai_Javascript___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
88+
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
8889
PHP_FE_END
8990
};
9091

@@ -167,8 +168,9 @@ PHP_MINIT_FUNCTION(Javascript)
167168

168169

169170
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Javascript", php_phongo_javascript_me);
170-
ce.create_object = php_phongo_javascript_create_object;
171171
php_phongo_javascript_ce = zend_register_internal_class(&ce TSRMLS_CC);
172+
php_phongo_javascript_ce->create_object = php_phongo_javascript_create_object;
173+
PHONGO_CE_INIT(php_phongo_javascript_ce);
172174

173175
zend_class_implements(php_phongo_javascript_ce TSRMLS_CC, 1, php_phongo_type_ce);
174176

src/BSON/MaxKey.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ PHONGO_API zend_class_entry *php_phongo_maxkey_ce;
5050

5151

5252
static zend_function_entry php_phongo_maxkey_me[] = {
53+
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
5354
PHP_FE_END
5455
};
5556

@@ -92,8 +93,9 @@ PHP_MINIT_FUNCTION(MaxKey)
9293

9394

9495
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "MaxKey", php_phongo_maxkey_me);
95-
ce.create_object = php_phongo_maxkey_create_object;
9696
php_phongo_maxkey_ce = zend_register_internal_class(&ce TSRMLS_CC);
97+
php_phongo_maxkey_ce->create_object = php_phongo_maxkey_create_object;
98+
PHONGO_CE_INIT(php_phongo_maxkey_ce);
9799

98100
zend_class_implements(php_phongo_maxkey_ce TSRMLS_CC, 1, php_phongo_type_ce);
99101

src/BSON/MinKey.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ PHONGO_API zend_class_entry *php_phongo_minkey_ce;
5050

5151

5252
static zend_function_entry php_phongo_minkey_me[] = {
53+
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
5354
PHP_FE_END
5455
};
5556

@@ -92,8 +93,9 @@ PHP_MINIT_FUNCTION(MinKey)
9293

9394

9495
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "MinKey", php_phongo_minkey_me);
95-
ce.create_object = php_phongo_minkey_create_object;
9696
php_phongo_minkey_ce = zend_register_internal_class(&ce TSRMLS_CC);
97+
php_phongo_minkey_ce->create_object = php_phongo_minkey_create_object;
98+
PHONGO_CE_INIT(php_phongo_minkey_ce);
9799

98100
zend_class_implements(php_phongo_minkey_ce TSRMLS_CC, 1, php_phongo_type_ce);
99101

src/BSON/ObjectID.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ ZEND_END_ARG_INFO();
116116
static zend_function_entry php_phongo_objectid_me[] = {
117117
PHP_ME(ObjectID, __construct, ai_ObjectID___construct, ZEND_ACC_PUBLIC)
118118
PHP_ME(ObjectID, __toString, ai_ObjectID___toString, ZEND_ACC_PUBLIC)
119+
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
119120
PHP_FE_END
120121
};
121122

@@ -186,6 +187,7 @@ PHP_MINIT_FUNCTION(ObjectID)
186187
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "ObjectID", php_phongo_objectid_me);
187188
php_phongo_objectid_ce = zend_register_internal_class(&ce TSRMLS_CC);
188189
php_phongo_objectid_ce->create_object = php_phongo_objectid_create_object;
190+
PHONGO_CE_INIT(php_phongo_objectid_ce);
189191

190192
zend_class_implements(php_phongo_objectid_ce TSRMLS_CC, 1, php_phongo_type_ce);
191193

src/BSON/Regex.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ static zend_function_entry php_phongo_regex_me[] = {
152152
PHP_ME(Regex, getPattern, ai_Regex_getPattern, ZEND_ACC_PUBLIC)
153153
PHP_ME(Regex, getFlags, ai_Regex_getFlags, ZEND_ACC_PUBLIC)
154154
PHP_ME(Regex, __toString, ai_Regex___toString, ZEND_ACC_PUBLIC)
155+
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
155156
PHP_FE_END
156157
};
157158

@@ -217,8 +218,9 @@ PHP_MINIT_FUNCTION(Regex)
217218
(void)type;(void)module_number;
218219

219220
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Regex", php_phongo_regex_me);
220-
ce.create_object = php_phongo_regex_create_object;
221221
php_phongo_regex_ce = zend_register_internal_class(&ce TSRMLS_CC);
222+
php_phongo_regex_ce->create_object = php_phongo_regex_create_object;
223+
PHONGO_CE_INIT(php_phongo_regex_ce);
222224

223225
zend_class_implements(php_phongo_regex_ce TSRMLS_CC, 1, php_phongo_type_ce);
224226

src/BSON/Timestamp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ ZEND_END_ARG_INFO();
103103
static zend_function_entry php_phongo_timestamp_me[] = {
104104
PHP_ME(Timestamp, __construct, ai_Timestamp___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
105105
PHP_ME(Timestamp, __toString, ai_Timestamp___toString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
106+
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
106107
PHP_FE_END
107108
};
108109

@@ -161,8 +162,9 @@ PHP_MINIT_FUNCTION(Timestamp)
161162
(void)type;(void)module_number;
162163

163164
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Timestamp", php_phongo_timestamp_me);
164-
ce.create_object = php_phongo_timestamp_create_object;
165165
php_phongo_timestamp_ce = zend_register_internal_class(&ce TSRMLS_CC);
166+
php_phongo_timestamp_ce->create_object = php_phongo_timestamp_create_object;
167+
PHONGO_CE_INIT(php_phongo_timestamp_ce);
166168

167169
zend_class_implements(php_phongo_timestamp_ce TSRMLS_CC, 1, php_phongo_type_ce);
168170

src/BSON/UTCDateTime.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ static zend_function_entry php_phongo_utcdatetime_me[] = {
135135
PHP_ME(UTCDateTime, __construct, ai_UTCDateTime___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
136136
PHP_ME(UTCDateTime, __toString, ai_UTCDateTime___toString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
137137
PHP_ME(UTCDateTime, toDateTime, ai_UTCDateTime_toDateTime, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
138+
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
138139
PHP_FE_END
139140
};
140141

@@ -201,8 +202,9 @@ PHP_MINIT_FUNCTION(UTCDateTime)
201202
(void)type;(void)module_number;
202203

203204
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "UTCDateTime", php_phongo_utcdatetime_me);
204-
ce.create_object = php_phongo_utcdatetime_create_object;
205205
php_phongo_utcdatetime_ce = zend_register_internal_class(&ce TSRMLS_CC);
206+
php_phongo_utcdatetime_ce->create_object = php_phongo_utcdatetime_create_object;
207+
PHONGO_CE_INIT(php_phongo_utcdatetime_ce);
206208

207209
zend_class_implements(php_phongo_utcdatetime_ce TSRMLS_CC, 1, php_phongo_type_ce);
208210

src/MongoDB/Exception/ConnectionTimeoutException.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ PHP_MINIT_FUNCTION(ConnectionTimeoutException)
6262

6363
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "ConnectionTimeoutException", php_phongo_connectiontimeoutexception_me);
6464
php_phongo_connectiontimeoutexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce, NULL TSRMLS_CC);
65-
PHONGO_CE_INIT(php_phongo_connectiontimeoutexception_ce);
6665

6766
return SUCCESS;
6867
}

src/MongoDB/Exception/DuplicateKeyException.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ PHP_MINIT_FUNCTION(DuplicateKeyException)
6262

6363
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "DuplicateKeyException", php_phongo_duplicatekeyexception_me);
6464
php_phongo_duplicatekeyexception_ce = zend_register_internal_class_ex(&ce, php_phongo_writeexception_ce, NULL TSRMLS_CC);
65-
PHONGO_CE_INIT(php_phongo_duplicatekeyexception_ce);
6665

6766
return SUCCESS;
6867
}

src/MongoDB/Exception/ExecutionTimeoutException.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ PHP_MINIT_FUNCTION(ExecutionTimeoutException)
6262

6363
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "ExecutionTimeoutException", php_phongo_executiontimeoutexception_me);
6464
php_phongo_executiontimeoutexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce, NULL TSRMLS_CC);
65-
PHONGO_CE_INIT(php_phongo_executiontimeoutexception_ce);
6665

6766
return SUCCESS;
6867
}

src/MongoDB/Exception/SSLConnectionException.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ PHP_MINIT_FUNCTION(SSLConnectionException)
6262

6363
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "SSLConnectionException", php_phongo_sslconnectionexception_me);
6464
php_phongo_sslconnectionexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce, NULL TSRMLS_CC);
65-
PHONGO_CE_INIT(php_phongo_sslconnectionexception_ce);
6665

6766
return SUCCESS;
6867
}

tests/bson/bson-binary_error-002.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
BSON BSON\Binary cannot be extended
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"?>
5+
--FILE--
6+
<?php
7+
require_once __DIR__ . "/../utils/basic.inc";
8+
9+
use MongoDB\BSON as BSON;
10+
11+
class MyBinary extends BSON\Binary {}
12+
13+
?>
14+
===DONE===
15+
<?php exit(0); ?>
16+
--EXPECTF--
17+
Fatal error: Class MyBinary may not inherit from final class (%SBSON\Binary) in %s on line %d

tests/bson/bson-binary_error-003.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
BSON BSON\Binary cannot be serialized
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"?>
5+
--FILE--
6+
<?php
7+
require_once __DIR__ . "/../utils/basic.inc";
8+
9+
use MongoDB\BSON as BSON;
10+
11+
echo throws(function() {
12+
serialize(new BSON\Binary('foo', BSON\Binary::TYPE_GENERIC));
13+
}, 'Exception'), "\n";
14+
15+
echo throws(function() {
16+
$classname = BSON_NAMESPACE . '\Binary';
17+
unserialize(sprintf('C:%d:"%s":0:{}', strlen($classname), $classname));
18+
}, 'Exception'), "\n";
19+
20+
?>
21+
===DONE===
22+
<?php exit(0); ?>
23+
--EXPECTF--
24+
OK: Got Exception
25+
Serialization of '%SBSON\Binary' is not allowed
26+
OK: Got Exception
27+
Unserialization of '%SBSON\Binary' is not allowed
28+
===DONE===
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
BSON BSON\Javascript cannot be extended
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"?>
5+
--FILE--
6+
<?php
7+
require_once __DIR__ . "/../utils/basic.inc";
8+
9+
use MongoDB\BSON as BSON;
10+
11+
class MyJavascript extends BSON\Javascript {}
12+
13+
?>
14+
===DONE===
15+
<?php exit(0); ?>
16+
--EXPECTF--
17+
Fatal error: Class MyJavascript may not inherit from final class (%SBSON\Javascript) in %s on line %d
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
BSON BSON\Javascript cannot be serialized
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"?>
5+
--FILE--
6+
<?php
7+
require_once __DIR__ . "/../utils/basic.inc";
8+
9+
use MongoDB\BSON as BSON;
10+
11+
echo throws(function() {
12+
serialize(new BSON\Javascript('function() {}'));
13+
}, 'Exception'), "\n";
14+
15+
echo throws(function() {
16+
$classname = BSON_NAMESPACE . '\Javascript';
17+
unserialize(sprintf('C:%d:"%s":0:{}', strlen($classname), $classname));
18+
}, 'Exception'), "\n";
19+
20+
?>
21+
===DONE===
22+
<?php exit(0); ?>
23+
--EXPECTF--
24+
OK: Got Exception
25+
Serialization of '%SBSON\Javascript' is not allowed
26+
OK: Got Exception
27+
Unserialization of '%SBSON\Javascript' is not allowed
28+
===DONE===

tests/bson/bson-maxkey_error-001.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
BSON BSON\MaxKey cannot be extended
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"?>
5+
--FILE--
6+
<?php
7+
require_once __DIR__ . "/../utils/basic.inc";
8+
9+
use MongoDB\BSON as BSON;
10+
11+
class MyMaxKey extends BSON\MaxKey {}
12+
13+
?>
14+
===DONE===
15+
<?php exit(0); ?>
16+
--EXPECTF--
17+
Fatal error: Class MyMaxKey may not inherit from final class (%SBSON\MaxKey) in %s on line %d

tests/bson/bson-maxkey_error-002.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
BSON BSON\MaxKey cannot be serialized
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"?>
5+
--FILE--
6+
<?php
7+
require_once __DIR__ . "/../utils/basic.inc";
8+
9+
use MongoDB\BSON as BSON;
10+
11+
echo throws(function() {
12+
serialize(new BSON\MaxKey());
13+
}, 'Exception'), "\n";
14+
15+
echo throws(function() {
16+
$classname = BSON_NAMESPACE . '\MaxKey';
17+
unserialize(sprintf('C:%d:"%s":0:{}', strlen($classname), $classname));
18+
}, 'Exception'), "\n";
19+
20+
?>
21+
===DONE===
22+
<?php exit(0); ?>
23+
--EXPECTF--
24+
OK: Got Exception
25+
Serialization of '%SBSON\MaxKey' is not allowed
26+
OK: Got Exception
27+
Unserialization of '%SBSON\MaxKey' is not allowed
28+
===DONE===

tests/bson/bson-minkey_error-001.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
BSON BSON\MinKey cannot be extended
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"?>
5+
--FILE--
6+
<?php
7+
require_once __DIR__ . "/../utils/basic.inc";
8+
9+
use MongoDB\BSON as BSON;
10+
11+
class MyMinKey extends BSON\MinKey {}
12+
13+
?>
14+
===DONE===
15+
<?php exit(0); ?>
16+
--EXPECTF--
17+
Fatal error: Class MyMinKey may not inherit from final class (%SBSON\MinKey) in %s on line %d

tests/bson/bson-minkey_error-002.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
BSON BSON\MinKey cannot be serialized
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"?>
5+
--FILE--
6+
<?php
7+
require_once __DIR__ . "/../utils/basic.inc";
8+
9+
use MongoDB\BSON as BSON;
10+
11+
echo throws(function() {
12+
serialize(new BSON\MinKey());
13+
}, 'Exception'), "\n";
14+
15+
echo throws(function() {
16+
$classname = BSON_NAMESPACE . '\MinKey';
17+
unserialize(sprintf('C:%d:"%s":0:{}', strlen($classname), $classname));
18+
}, 'Exception'), "\n";
19+
20+
?>
21+
===DONE===
22+
<?php exit(0); ?>
23+
--EXPECTF--
24+
OK: Got Exception
25+
Serialization of '%SBSON\MinKey' is not allowed
26+
OK: Got Exception
27+
Unserialization of '%SBSON\MinKey' is not allowed
28+
===DONE===
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
BSON BSON\ObjectID cannot be extended
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"?>
5+
--FILE--
6+
<?php
7+
require_once __DIR__ . "/../utils/basic.inc";
8+
9+
use MongoDB\BSON as BSON;
10+
11+
class MyObjectID extends BSON\ObjectID {}
12+
13+
?>
14+
===DONE===
15+
<?php exit(0); ?>
16+
--EXPECTF--
17+
Fatal error: Class MyObjectID may not inherit from final class (%SBSON\ObjectID) in %s on line %d

0 commit comments

Comments
 (0)