Skip to content

Commit 46c6055

Browse files
authored
PHPC-2248: Remove Serializable implementations (#1663)
1 parent a2c7252 commit 46c6055

File tree

92 files changed

+130
-2159
lines changed

Some content is hidden

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

92 files changed

+130
-2159
lines changed

UPGRADE-2.0.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ UPGRADE FROM 1.x to 2.0
2323
`MongoDB\Driver\Cursor::getId()` and
2424
`MongoDB\Driver\CursorInterface::getId()` now return a `MongoDB\BSON\Int64`
2525
instance.
26-
27-
* The `--with-libbson` and `--with-libmongoc` configure options have been
28-
removed. Use `--with-mongodb-system-libs` instead.
29-
26+
* The `--with-libbson` and `--with-libmongoc` configure options have been
27+
removed. Use `--with-mongodb-system-libs` instead.
28+
* All classes that previously implemented the `Serializable` interface no
29+
longer implement this interface.

src/BSON/Binary.c

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
*/
1616

1717
#include <php.h>
18-
#include <zend_smart_str.h>
1918
#include <ext/standard/base64.h>
20-
#include <ext/standard/php_var.h>
2119
#include <Zend/zend_interfaces.h>
2220

2321
#include "php_phongo.h"
@@ -184,60 +182,6 @@ static PHP_METHOD(MongoDB_BSON_Binary, jsonSerialize)
184182
ADD_ASSOC_STRINGL(return_value, "$type", type, type_len);
185183
}
186184

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-
241185
static PHP_METHOD(MongoDB_BSON_Binary, __serialize)
242186
{
243187
PHONGO_PARSE_PARAMETERS_NONE();
@@ -339,7 +283,7 @@ static HashTable* php_phongo_binary_get_properties(zend_object* object)
339283

340284
void php_phongo_binary_init_ce(INIT_FUNC_ARGS)
341285
{
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);
286+
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);
343287
php_phongo_binary_ce->create_object = php_phongo_binary_create_object;
344288

345289
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 & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
#include "bson/bson.h"
1818

1919
#include <php.h>
20-
#include <zend_smart_str.h>
21-
#include <ext/standard/php_var.h>
2220
#include <Zend/zend_interfaces.h>
2321

2422
#include "php_phongo.h"
@@ -147,60 +145,6 @@ static PHP_METHOD(MongoDB_BSON_DBPointer, jsonSerialize)
147145
ADD_ASSOC_ZVAL(return_value, "$dbPointer", &zdb_pointer);
148146
}
149147

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-
204148
static PHP_METHOD(MongoDB_BSON_DBPointer, __serialize)
205149
{
206150
PHONGO_PARSE_PARAMETERS_NONE();
@@ -299,7 +243,7 @@ static HashTable* php_phongo_dbpointer_get_properties(zend_object* object)
299243

300244
void php_phongo_dbpointer_init_ce(INIT_FUNC_ARGS)
301245
{
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);
246+
php_phongo_dbpointer_ce = register_class_MongoDB_BSON_DBPointer(php_phongo_json_serializable_ce, php_phongo_type_ce, zend_ce_stringable);
303247
php_phongo_dbpointer_ce->create_object = php_phongo_dbpointer_create_object;
304248

305249
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 & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
#include "bson/bson.h"
1818

1919
#include <php.h>
20-
#include <zend_smart_str.h>
21-
#include <ext/standard/php_var.h>
2220
#include <Zend/zend_interfaces.h>
2321

2422
#include "php_phongo.h"
@@ -143,61 +141,6 @@ static PHP_METHOD(MongoDB_BSON_Decimal128, jsonSerialize)
143141
ADD_ASSOC_STRING(return_value, "$numberDecimal", outbuf);
144142
}
145143

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-
201144
static PHP_METHOD(MongoDB_BSON_Decimal128, __serialize)
202145
{
203146
PHONGO_PARSE_PARAMETERS_NONE();
@@ -275,7 +218,7 @@ static HashTable* php_phongo_decimal128_get_properties(zend_object* object)
275218

276219
void php_phongo_decimal128_init_ce(INIT_FUNC_ARGS)
277220
{
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);
221+
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);
279222
php_phongo_decimal128_ce->create_object = php_phongo_decimal128_create_object;
280223

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

0 commit comments

Comments
 (0)