Skip to content

Commit 3db1260

Browse files
authored
PHPC-1956: Remove disabled __wakeup function in non-serializable classes (#1513)
* Remove shared function entries for disabled __construct and __wakeup methods These have been obsolete since the PHONGO_DISABLED_CONSTRUCTOR and PHONGO_DISABLED_WAKEUP macros were introduced in 6887226. * Remove extra vim foldmarkers and fix balancing for last marker * PHPC-1956: Remove disabled __wakeup function in non-serializable classes This function was not necessary since PHP 7.0 allowed disabling serialization via object handlers. The PHONGO_DISABLED_WAKEUP macro is no longer used and has been removed. * Remove obsolete serialization test This is superseded by the new manager-serialization_error tests.
1 parent 5a5d6bf commit 3db1260

File tree

84 files changed

+107
-332
lines changed

Some content is hidden

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

84 files changed

+107
-332
lines changed

php_phongo.c

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,28 @@ zend_object_handlers* phongo_get_std_object_handlers(void)
5656
/* }}} */
5757

5858
/* {{{ Memory allocation wrappers */
59-
static void* php_phongo_malloc(size_t num_bytes) /* {{{ */
59+
static void* php_phongo_malloc(size_t num_bytes)
6060
{
6161
return pemalloc(num_bytes, 1);
62-
} /* }}} */
62+
}
6363

64-
static void* php_phongo_calloc(size_t num_members, size_t num_bytes) /* {{{ */
64+
static void* php_phongo_calloc(size_t num_members, size_t num_bytes)
6565
{
6666
return pecalloc(num_members, num_bytes, 1);
67-
} /* }}} */
67+
}
6868

69-
static void* php_phongo_realloc(void* mem, size_t num_bytes) /* {{{ */
69+
static void* php_phongo_realloc(void* mem, size_t num_bytes)
7070
{
7171
return perealloc(mem, num_bytes, 1);
72-
} /* }}} */
72+
}
7373

74-
static void php_phongo_free(void* mem) /* {{{ */
74+
static void php_phongo_free(void* mem)
7575
{
7676
if (mem) {
7777
pefree(mem, 1);
7878
}
79-
} /* }}} */
79+
}
80+
/* }}} */
8081

8182
PHP_RINIT_FUNCTION(mongodb) /* {{{ */
8283
{
@@ -153,12 +154,12 @@ static zend_class_entry* php_phongo_fetch_internal_class(const char* class_name,
153154
return NULL;
154155
}
155156

156-
static HashTable* php_phongo_std_get_gc(phongo_compat_object_handler_type* object, zval** table, int* n) /* {{{ */
157+
static HashTable* php_phongo_std_get_gc(phongo_compat_object_handler_type* object, zval** table, int* n)
157158
{
158159
*table = NULL;
159160
*n = 0;
160161
return zend_std_get_properties(object);
161-
} /* }}} */
162+
}
162163

163164
PHP_MINIT_FUNCTION(mongodb) /* {{{ */
164165
{
@@ -515,20 +516,6 @@ PHP_MINFO_FUNCTION(mongodb) /* {{{ */
515516
phongo_display_ini_entries(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU);
516517
} /* }}} */
517518

518-
/* {{{ Shared function entries for disabling constructors and unserialize() */
519-
PHP_FUNCTION(MongoDB_disabled___construct) /* {{{ */
520-
{
521-
phongo_throw_exception(PHONGO_ERROR_RUNTIME, "Accessing private constructor");
522-
} /* }}} */
523-
524-
PHP_FUNCTION(MongoDB_disabled___wakeup) /* {{{ */
525-
{
526-
PHONGO_PARSE_PARAMETERS_NONE();
527-
528-
phongo_throw_exception(PHONGO_ERROR_RUNTIME, "%s", "MongoDB\\Driver objects cannot be serialized");
529-
} /* }}} */
530-
/* }}} */
531-
532519
/* {{{ Module dependencies and module entry */
533520
static const zend_module_dep mongodb_deps[] = {
534521
/* clang-format off */

php_phongo.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,4 @@ zend_object_handlers* phongo_get_std_object_handlers(void);
117117
phongo_throw_exception(PHONGO_ERROR_RUNTIME, "Accessing private constructor"); \
118118
}
119119

120-
#define PHONGO_DISABLED_WAKEUP(classname) \
121-
static PHP_METHOD(classname, __wakeup) \
122-
{ \
123-
PHONGO_PARSE_PARAMETERS_NONE(); \
124-
phongo_throw_exception(PHONGO_ERROR_RUNTIME, "MongoDB\\Driver objects cannot be serialized"); \
125-
}
126-
127-
/* Shared function entries for disabling constructors and unserialize() */
128-
PHP_FUNCTION(MongoDB_disabled___construct);
129-
PHP_FUNCTION(MongoDB_disabled___wakeup);
130-
131120
#endif /* PHONGO_H */

src/BSON/Iterator.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ static HashTable* php_phongo_iterator_get_properties_hash(phongo_compat_object_h
169169
}
170170

171171
PHONGO_DISABLED_CONSTRUCTOR(MongoDB_BSON_Iterator)
172-
PHONGO_DISABLED_WAKEUP(MongoDB_BSON_Iterator)
173172

174173
static PHP_METHOD(MongoDB_BSON_Iterator, current)
175174
{

src/BSON/Iterator.stub.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,4 @@ final public function next(): void {}
3030
final public function rewind(): void {}
3131

3232
final public function valid(): bool {}
33-
34-
final public function __wakeup(): void {}
3533
}

src/BSON/Iterator_arginfo.h

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/MongoDB/BulkWrite.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,6 @@ static PHP_METHOD(MongoDB_Driver_BulkWrite, count)
542542
RETURN_LONG(intern->num_ops);
543543
}
544544

545-
PHONGO_DISABLED_WAKEUP(MongoDB_Driver_BulkWrite)
546-
547545
/* MongoDB\Driver\BulkWrite object handlers */
548546
static zend_object_handlers php_phongo_handler_bulkwrite;
549547

src/MongoDB/BulkWrite.stub.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,4 @@ public function update(array|object $filter, array|object $newObj, ?array $updat
3939
*/
4040
public function update($filter, $newObj, ?array $updateOptions = null): void {}
4141
#endif
42-
43-
final public function __wakeup(): void {}
4442
}

src/MongoDB/BulkWrite_arginfo.h

Lines changed: 1 addition & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/MongoDB/ClientEncryption.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,6 @@ static PHP_METHOD(MongoDB_Driver_ClientEncryption, rewrapManyDataKey)
473473
mongoc_client_encryption_rewrap_many_datakey_result_destroy(result);
474474
}
475475

476-
PHONGO_DISABLED_WAKEUP(MongoDB_Driver_ClientEncryption)
477-
478476
/* MongoDB\Driver\ClientEncryption object handlers */
479477
static zend_object_handlers php_phongo_handler_clientencryption;
480478

src/MongoDB/ClientEncryption.stub.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,4 @@ final public function rewrapManyDataKey(array|object $filter, ?array $options =
9494
/** @param array|object $filter */
9595
final public function rewrapManyDataKey($filter, ?array $options = null): object {}
9696
#endif
97-
98-
final public function __wakeup(): void {}
9997
}

src/MongoDB/ClientEncryption_arginfo.h

Lines changed: 1 addition & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/MongoDB/Command.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ static PHP_METHOD(MongoDB_Driver_Command, __construct)
115115
php_phongo_command_init(intern, document, options);
116116
}
117117

118-
PHONGO_DISABLED_WAKEUP(MongoDB_Driver_Command)
119-
120118
/* MongoDB\Driver\Command object handlers */
121119
static zend_object_handlers php_phongo_handler_command;
122120

src/MongoDB/Command.stub.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,4 @@ final public function __construct(array|object $document, ?array $commandOptions
1515
/** @param array|object $document */
1616
final public function __construct($document, ?array $commandOptions = null) {}
1717
#endif
18-
19-
final public function __wakeup(): void {}
2018
}

src/MongoDB/Command_arginfo.h

Lines changed: 1 addition & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/MongoDB/Cursor.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ static PHP_METHOD(MongoDB_Driver_Cursor, rewind)
289289
}
290290

291291
PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_Cursor)
292-
PHONGO_DISABLED_WAKEUP(MongoDB_Driver_Cursor)
293292

294293
/* MongoDB\Driver\Cursor object handlers */
295294
static zend_object_handlers php_phongo_handler_cursor;

src/MongoDB/Cursor.stub.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,4 @@ final public function setTypeMap(array $typemap): void {}
3535
final public function toArray(): array {}
3636

3737
public function valid(): bool {}
38-
39-
final public function __wakeup(): void {}
4038
}

src/MongoDB/Cursor_arginfo.h

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/MongoDB/Manager.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,6 @@ static bool php_phongo_manager_select_server(bool for_writes, bool inherit_read_
242242
return false;
243243
}
244244

245-
PHONGO_DISABLED_WAKEUP(MongoDB_Driver_Manager)
246-
247245
/* Constructs a new Manager */
248246
static PHP_METHOD(MongoDB_Driver_Manager, __construct)
249247
{

src/MongoDB/Manager.stub.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,4 @@ final public function removeSubscriber(Monitoring\Subscriber $subscriber): void
6262
final public function selectServer(?ReadPreference $readPreference = null): Server {}
6363

6464
final public function startSession(?array $options = null): Session {}
65-
66-
final public function __wakeup(): void {}
6765
}

src/MongoDB/Manager_arginfo.h

Lines changed: 1 addition & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/MongoDB/Monitoring/CommandFailedEvent.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
zend_class_entry* php_phongo_commandfailedevent_ce;
3131

3232
PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_Monitoring_CommandFailedEvent)
33-
PHONGO_DISABLED_WAKEUP(MongoDB_Driver_Monitoring_CommandFailedEvent)
3433

3534
/* Returns the command name for this event */
3635
static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getCommandName)

src/MongoDB/Monitoring/CommandFailedEvent.stub.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,4 @@ final public function getServer(): \MongoDB\Driver\Server {}
2828
final public function getServiceId(): ?\MongoDB\BSON\ObjectId {}
2929

3030
final public function getServerConnectionId(): ?int {}
31-
32-
final public function __wakeup(): void {}
3331
}

0 commit comments

Comments
 (0)