Skip to content

Commit 52b93ed

Browse files
committed
PHPC-2248: Remove Serializable implementations
1 parent ca52367 commit 52b93ed

File tree

101 files changed

+140
-2218
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+140
-2218
lines changed

UPGRADE-2.0.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ UPGRADE FROM 1.x to 2.0
44
* The `getServer()` method has been removed from the CommandFailedEvent,
55
CommandStartedEvent, and CommandSucceededEvent event classes. The `getHost()`
66
and `getPort()` methods have been added in its place.
7+
* All classes that previously implemented the `Serializable` interface no
8+
longer implement this. This changes the serialization format, but the
9+
ability to serialize and unserialize these classes remains as-is.

src/BSON/Binary.c

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -184,60 +184,6 @@ static PHP_METHOD(MongoDB_BSON_Binary, jsonSerialize)
184184
ADD_ASSOC_STRINGL(return_value, "$type", type, type_len);
185185
}
186186

187-
static PHP_METHOD(MongoDB_BSON_Binary, serialize)
188-
{
189-
php_phongo_binary_t* intern;
190-
zval retval;
191-
php_serialize_data_t var_hash;
192-
smart_str buf = { 0 };
193-
194-
intern = Z_BINARY_OBJ_P(getThis());
195-
196-
PHONGO_PARSE_PARAMETERS_NONE();
197-
198-
array_init_size(&retval, 2);
199-
ADD_ASSOC_STRINGL(&retval, "data", intern->data, intern->data_len);
200-
ADD_ASSOC_LONG_EX(&retval, "type", intern->type);
201-
202-
PHP_VAR_SERIALIZE_INIT(var_hash);
203-
php_var_serialize(&buf, &retval, &var_hash);
204-
smart_str_0(&buf);
205-
PHP_VAR_SERIALIZE_DESTROY(var_hash);
206-
207-
PHONGO_RETVAL_SMART_STR(buf);
208-
209-
smart_str_free(&buf);
210-
zval_ptr_dtor(&retval);
211-
}
212-
213-
static PHP_METHOD(MongoDB_BSON_Binary, unserialize)
214-
{
215-
php_phongo_binary_t* intern;
216-
char* serialized;
217-
size_t serialized_len;
218-
zval props;
219-
php_unserialize_data_t var_hash;
220-
221-
intern = Z_BINARY_OBJ_P(getThis());
222-
223-
PHONGO_PARSE_PARAMETERS_START(1, 1)
224-
Z_PARAM_STRING(serialized, serialized_len)
225-
PHONGO_PARSE_PARAMETERS_END();
226-
227-
PHP_VAR_UNSERIALIZE_INIT(var_hash);
228-
if (!php_var_unserialize(&props, (const unsigned char**) &serialized, (unsigned char*) serialized + serialized_len, &var_hash)) {
229-
zval_ptr_dtor(&props);
230-
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE, "%s unserialization failed", ZSTR_VAL(php_phongo_binary_ce->name));
231-
232-
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
233-
return;
234-
}
235-
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
236-
237-
php_phongo_binary_init_from_hash(intern, HASH_OF(&props));
238-
zval_ptr_dtor(&props);
239-
}
240-
241187
static PHP_METHOD(MongoDB_BSON_Binary, __serialize)
242188
{
243189
PHONGO_PARSE_PARAMETERS_NONE();
@@ -339,7 +285,7 @@ static HashTable* php_phongo_binary_get_properties(zend_object* object)
339285

340286
void php_phongo_binary_init_ce(INIT_FUNC_ARGS)
341287
{
342-
php_phongo_binary_ce = register_class_MongoDB_BSON_Binary(php_phongo_binary_interface_ce, php_phongo_json_serializable_ce, php_phongo_type_ce, zend_ce_serializable, zend_ce_stringable);
288+
php_phongo_binary_ce = register_class_MongoDB_BSON_Binary(php_phongo_binary_interface_ce, php_phongo_json_serializable_ce, php_phongo_type_ce, zend_ce_stringable);
343289
php_phongo_binary_ce->create_object = php_phongo_binary_create_object;
344290

345291
memcpy(&php_phongo_handler_binary, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));

src/BSON/Binary.stub.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace MongoDB\BSON;
99

10-
final class Binary implements BinaryInterface, \JsonSerializable, Type, \Serializable, \Stringable
10+
final class Binary implements BinaryInterface, \JsonSerializable, Type, \Stringable
1111
{
1212
/**
1313
* @var int
@@ -79,10 +79,6 @@ final public static function __set_state(array $properties): Binary {}
7979

8080
final public function __toString(): string {}
8181

82-
final public function serialize(): string {}
83-
84-
final public function unserialize(string $data): void {}
85-
8682
final public function __unserialize(array $data): void {}
8783

8884
final public function __serialize(): array {}

src/BSON/Binary_arginfo.h

Lines changed: 3 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/BSON/DBPointer.c

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -147,60 +147,6 @@ static PHP_METHOD(MongoDB_BSON_DBPointer, jsonSerialize)
147147
ADD_ASSOC_ZVAL(return_value, "$dbPointer", &zdb_pointer);
148148
}
149149

150-
static PHP_METHOD(MongoDB_BSON_DBPointer, serialize)
151-
{
152-
php_phongo_dbpointer_t* intern;
153-
zval retval;
154-
php_serialize_data_t var_hash;
155-
smart_str buf = { 0 };
156-
157-
intern = Z_DBPOINTER_OBJ_P(getThis());
158-
159-
PHONGO_PARSE_PARAMETERS_NONE();
160-
161-
array_init_size(&retval, 2);
162-
ADD_ASSOC_STRINGL(&retval, "ref", intern->ref, intern->ref_len);
163-
ADD_ASSOC_STRING(&retval, "id", intern->id);
164-
165-
PHP_VAR_SERIALIZE_INIT(var_hash);
166-
php_var_serialize(&buf, &retval, &var_hash);
167-
smart_str_0(&buf);
168-
PHP_VAR_SERIALIZE_DESTROY(var_hash);
169-
170-
PHONGO_RETVAL_SMART_STR(buf);
171-
172-
smart_str_free(&buf);
173-
zval_ptr_dtor(&retval);
174-
}
175-
176-
static PHP_METHOD(MongoDB_BSON_DBPointer, unserialize)
177-
{
178-
php_phongo_dbpointer_t* intern;
179-
char* serialized;
180-
size_t serialized_len;
181-
zval props;
182-
php_unserialize_data_t var_hash;
183-
184-
intern = Z_DBPOINTER_OBJ_P(getThis());
185-
186-
PHONGO_PARSE_PARAMETERS_START(1, 1)
187-
Z_PARAM_STRING(serialized, serialized_len)
188-
PHONGO_PARSE_PARAMETERS_END();
189-
190-
PHP_VAR_UNSERIALIZE_INIT(var_hash);
191-
if (!php_var_unserialize(&props, (const unsigned char**) &serialized, (unsigned char*) serialized + serialized_len, &var_hash)) {
192-
zval_ptr_dtor(&props);
193-
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE, "%s unserialization failed", ZSTR_VAL(php_phongo_dbpointer_ce->name));
194-
195-
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
196-
return;
197-
}
198-
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
199-
200-
php_phongo_dbpointer_init_from_hash(intern, HASH_OF(&props));
201-
zval_ptr_dtor(&props);
202-
}
203-
204150
static PHP_METHOD(MongoDB_BSON_DBPointer, __serialize)
205151
{
206152
PHONGO_PARSE_PARAMETERS_NONE();
@@ -299,7 +245,7 @@ static HashTable* php_phongo_dbpointer_get_properties(zend_object* object)
299245

300246
void php_phongo_dbpointer_init_ce(INIT_FUNC_ARGS)
301247
{
302-
php_phongo_dbpointer_ce = register_class_MongoDB_BSON_DBPointer(php_phongo_json_serializable_ce, php_phongo_type_ce, zend_ce_serializable, zend_ce_stringable);
248+
php_phongo_dbpointer_ce = register_class_MongoDB_BSON_DBPointer(php_phongo_json_serializable_ce, php_phongo_type_ce, zend_ce_stringable);
303249
php_phongo_dbpointer_ce->create_object = php_phongo_dbpointer_create_object;
304250

305251
memcpy(&php_phongo_handler_dbpointer, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));

src/BSON/DBPointer.stub.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,14 @@
66
*/
77

88
namespace MongoDB\BSON;
9-
final class DBPointer implements \JsonSerializable, Type, \Serializable, \Stringable
9+
final class DBPointer implements \JsonSerializable, Type, \Stringable
1010
{
1111
final private function __construct() {}
1212

1313
final public static function __set_state(array $properties): DBPointer {}
1414

1515
final public function __toString(): string {}
1616

17-
final public function serialize(): string {}
18-
19-
final public function unserialize(string $data): void {}
20-
2117
final public function __unserialize(array $data): void {}
2218

2319
final public function __serialize(): array {}

src/BSON/DBPointer_arginfo.h

Lines changed: 3 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/BSON/Decimal128.c

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -143,61 +143,6 @@ static PHP_METHOD(MongoDB_BSON_Decimal128, jsonSerialize)
143143
ADD_ASSOC_STRING(return_value, "$numberDecimal", outbuf);
144144
}
145145

146-
static PHP_METHOD(MongoDB_BSON_Decimal128, serialize)
147-
{
148-
php_phongo_decimal128_t* intern;
149-
zval retval;
150-
php_serialize_data_t var_hash;
151-
smart_str buf = { 0 };
152-
char outbuf[BSON_DECIMAL128_STRING];
153-
154-
intern = Z_DECIMAL128_OBJ_P(getThis());
155-
156-
PHONGO_PARSE_PARAMETERS_NONE();
157-
158-
bson_decimal128_to_string(&intern->decimal, outbuf);
159-
array_init_size(&retval, 1);
160-
ADD_ASSOC_STRING(&retval, "dec", outbuf);
161-
162-
PHP_VAR_SERIALIZE_INIT(var_hash);
163-
php_var_serialize(&buf, &retval, &var_hash);
164-
smart_str_0(&buf);
165-
PHP_VAR_SERIALIZE_DESTROY(var_hash);
166-
167-
PHONGO_RETVAL_SMART_STR(buf);
168-
169-
smart_str_free(&buf);
170-
zval_ptr_dtor(&retval);
171-
}
172-
173-
static PHP_METHOD(MongoDB_BSON_Decimal128, unserialize)
174-
{
175-
php_phongo_decimal128_t* intern;
176-
char* serialized;
177-
size_t serialized_len;
178-
zval props;
179-
php_unserialize_data_t var_hash;
180-
181-
intern = Z_DECIMAL128_OBJ_P(getThis());
182-
183-
PHONGO_PARSE_PARAMETERS_START(1, 1)
184-
Z_PARAM_STRING(serialized, serialized_len)
185-
PHONGO_PARSE_PARAMETERS_END();
186-
187-
PHP_VAR_UNSERIALIZE_INIT(var_hash);
188-
if (!php_var_unserialize(&props, (const unsigned char**) &serialized, (unsigned char*) serialized + serialized_len, &var_hash)) {
189-
zval_ptr_dtor(&props);
190-
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE, "%s unserialization failed", ZSTR_VAL(php_phongo_decimal128_ce->name));
191-
192-
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
193-
return;
194-
}
195-
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
196-
197-
php_phongo_decimal128_init_from_hash(intern, HASH_OF(&props));
198-
zval_ptr_dtor(&props);
199-
}
200-
201146
static PHP_METHOD(MongoDB_BSON_Decimal128, __serialize)
202147
{
203148
PHONGO_PARSE_PARAMETERS_NONE();
@@ -275,7 +220,7 @@ static HashTable* php_phongo_decimal128_get_properties(zend_object* object)
275220

276221
void php_phongo_decimal128_init_ce(INIT_FUNC_ARGS)
277222
{
278-
php_phongo_decimal128_ce = register_class_MongoDB_BSON_Decimal128(php_phongo_decimal128_interface_ce, php_phongo_json_serializable_ce, php_phongo_type_ce, zend_ce_serializable, zend_ce_stringable);
223+
php_phongo_decimal128_ce = register_class_MongoDB_BSON_Decimal128(php_phongo_decimal128_interface_ce, php_phongo_json_serializable_ce, php_phongo_type_ce, zend_ce_stringable);
279224
php_phongo_decimal128_ce->create_object = php_phongo_decimal128_create_object;
280225

281226
memcpy(&php_phongo_handler_decimal128, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));

src/BSON/Decimal128.stub.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,14 @@
77

88
namespace MongoDB\BSON;
99

10-
final class Decimal128 implements Decimal128Interface, \JsonSerializable, Type, \Serializable, \Stringable
10+
final class Decimal128 implements Decimal128Interface, \JsonSerializable, Type, \Stringable
1111
{
1212
final public function __construct(string $value) {}
1313

1414
final public function __toString(): string {}
1515

1616
final public static function __set_state(array $properties): Decimal128 {}
1717

18-
final public function serialize(): string {}
19-
20-
final public function unserialize(string $data): void {}
21-
2218
final public function __unserialize(array $data): void {}
2319

2420
final public function __serialize(): array {}

0 commit comments

Comments
 (0)