Skip to content

PHPC-2351: Remove CursorId class #1664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions UPGRADE-2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ UPGRADE FROM 1.x to 2.0
implementing classes to also implement iterator methods. The return types for
the `key` and `current` methods have been narrowed to the types returned by
cursor instances.
* The `MongoDB\Driver\CursorId` class was removed.
`MongoDB\Driver\Cursor::getId()` and
`MongoDB\Driver\CursorInterface::getId()` now return a `MongoDB\BSON\Int64`
instance.
1 change: 0 additions & 1 deletion config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ if test "$PHP_MONGODB" != "no"; then
src/MongoDB/ClientEncryption.c \
src/MongoDB/Command.c \
src/MongoDB/Cursor.c \
src/MongoDB/CursorId.c \
src/MongoDB/CursorInterface.c \
src/MongoDB/Manager.c \
src/MongoDB/Query.c \
Expand Down
2 changes: 1 addition & 1 deletion config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ if (PHP_MONGODB != "no") {
EXTENSION("mongodb", "php_phongo.c", null, PHP_MONGODB_CFLAGS);
MONGODB_ADD_SOURCES("/src", "phongo_apm.c phongo_bson.c phongo_bson_encode.c phongo_client.c phongo_compat.c phongo_error.c phongo_execute.c phongo_ini.c phongo_log.c phongo_util.c");
MONGODB_ADD_SOURCES("/src/BSON", "Binary.c BinaryInterface.c Document.c Iterator.c DBPointer.c Decimal128.c Decimal128Interface.c Int64.c Javascript.c JavascriptInterface.c MaxKey.c MaxKeyInterface.c MinKey.c MinKeyInterface.c ObjectId.c ObjectIdInterface.c PackedArray.c Persistable.c Regex.c RegexInterface.c Serializable.c Symbol.c Timestamp.c TimestampInterface.c Type.c Undefined.c Unserializable.c UTCDateTime.c UTCDateTimeInterface.c");
MONGODB_ADD_SOURCES("/src/MongoDB", "BulkWrite.c ClientEncryption.c Command.c Cursor.c CursorId.c CursorInterface.c Manager.c Query.c ReadConcern.c ReadPreference.c Server.c ServerApi.c ServerDescription.c Session.c TopologyDescription.c WriteConcern.c WriteConcernError.c WriteError.c WriteResult.c");
MONGODB_ADD_SOURCES("/src/MongoDB", "BulkWrite.c ClientEncryption.c Command.c Cursor.c CursorInterface.c Manager.c Query.c ReadConcern.c ReadPreference.c Server.c ServerApi.c ServerDescription.c Session.c TopologyDescription.c WriteConcern.c WriteConcernError.c WriteError.c WriteResult.c");
MONGODB_ADD_SOURCES("/src/MongoDB/Exception", "AuthenticationException.c BulkWriteException.c CommandException.c ConnectionException.c ConnectionTimeoutException.c EncryptionException.c Exception.c ExecutionTimeoutException.c InvalidArgumentException.c LogicException.c RuntimeException.c ServerException.c SSLConnectionException.c UnexpectedValueException.c WriteException.c");
MONGODB_ADD_SOURCES("/src/MongoDB/Monitoring", "CommandFailedEvent.c CommandStartedEvent.c CommandSubscriber.c CommandSucceededEvent.c LogSubscriber.c SDAMSubscriber.c Subscriber.c ServerChangedEvent.c ServerClosedEvent.c ServerHeartbeatFailedEvent.c ServerHeartbeatStartedEvent.c ServerHeartbeatSucceededEvent.c ServerOpeningEvent.c TopologyChangedEvent.c TopologyClosedEvent.c TopologyOpeningEvent.c functions.c");
MONGODB_ADD_SOURCES("/src/libmongoc/src/common", PHP_MONGODB_COMMON_SOURCES);
Expand Down
1 change: 0 additions & 1 deletion php_phongo.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ PHP_MINIT_FUNCTION(mongodb) /* {{{ */
php_phongo_clientencryption_init_ce(INIT_FUNC_ARGS_PASSTHRU);
php_phongo_command_init_ce(INIT_FUNC_ARGS_PASSTHRU);
php_phongo_cursor_init_ce(INIT_FUNC_ARGS_PASSTHRU);
php_phongo_cursorid_init_ce(INIT_FUNC_ARGS_PASSTHRU);
php_phongo_manager_init_ce(INIT_FUNC_ARGS_PASSTHRU);
php_phongo_query_init_ce(INIT_FUNC_ARGS_PASSTHRU);
php_phongo_readconcern_init_ce(INIT_FUNC_ARGS_PASSTHRU);
Expand Down
25 changes: 2 additions & 23 deletions src/MongoDB/Cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,6 @@ static int php_phongo_cursor_to_array_apply(zend_object_iterator* iter, void* pu
return ZEND_HASH_APPLY_KEEP;
}

static void php_phongo_cursor_id_new_from_id(zval* object, int64_t cursorid)
{
php_phongo_cursorid_t* intern;

object_init_ex(object, php_phongo_cursorid_ce);

intern = Z_CURSORID_OBJ_P(object);
intern->id = cursorid;
intern->initialized = true;
}

/* Returns an array of all result documents for this cursor */
static PHP_METHOD(MongoDB_Driver_Cursor, toArray)
{
Expand All @@ -143,22 +132,12 @@ static PHP_METHOD(MongoDB_Driver_Cursor, toArray)
static PHP_METHOD(MongoDB_Driver_Cursor, getId)
{
php_phongo_cursor_t* intern;
zend_bool asInt64 = false;

intern = Z_CURSOR_OBJ_P(getThis());

PHONGO_PARSE_PARAMETERS_START(0, 1)
Z_PARAM_OPTIONAL
Z_PARAM_BOOL(asInt64)
PHONGO_PARSE_PARAMETERS_END();

if (asInt64) {
phongo_int64_new(return_value, mongoc_cursor_get_id(intern->cursor));
} else {
php_error_docref(NULL, E_DEPRECATED, "The method \"MongoDB\\Driver\\Cursor::getId\" will no longer return a \"MongoDB\\Driver\\CursorId\" instance in the future. Pass \"true\" as argument to change to the new behavior and receive a \"MongoDB\\BSON\\Int64\" instance instead.");
PHONGO_PARSE_PARAMETERS_NONE();

php_phongo_cursor_id_new_from_id(return_value, mongoc_cursor_get_id(intern->cursor));
}
phongo_int64_new(return_value, mongoc_cursor_get_id(intern->cursor));
}

/* Returns the Server object to which this cursor is attached */
Expand Down
2 changes: 1 addition & 1 deletion src/MongoDB/Cursor.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final private function __construct() {}

public function current(): array|object|null {}

final public function getId(bool $asInt64 = false): CursorId|\MongoDB\BSON\Int64 {}
final public function getId(): \MongoDB\BSON\Int64 {}

final public function getServer(): Server {}

Expand Down
249 changes: 0 additions & 249 deletions src/MongoDB/CursorId.c

This file was deleted.

25 changes: 0 additions & 25 deletions src/MongoDB/CursorId.stub.php

This file was deleted.

Loading
Loading