Skip to content

Commit d3f74f1

Browse files
committed
PHPC-2351: Remove CursorId class
1 parent 26a503a commit d3f74f1

35 files changed

+23
-710
lines changed

UPGRADE-2.0.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ UPGRADE FROM 1.x to 2.0
1515
implementing classes to also implement iterator methods. The return types for
1616
the `key` and `current` methods have been narrowed to the types returned by
1717
cursor instances.
18+
* The `MongoDB\Driver\CursorId` class was removed.
19+
`MongoDB\Driver\Cursor::getId()` and
20+
`MongoDB\Driver\CursorInterface::getId()` now return a `MongoDB\BSON\Int64`
21+
instance.

config.m4

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ if test "$PHP_MONGODB" != "no"; then
169169
src/MongoDB/ClientEncryption.c \
170170
src/MongoDB/Command.c \
171171
src/MongoDB/Cursor.c \
172-
src/MongoDB/CursorId.c \
173172
src/MongoDB/CursorInterface.c \
174173
src/MongoDB/Manager.c \
175174
src/MongoDB/Query.c \

config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ if (PHP_MONGODB != "no") {
116116
EXTENSION("mongodb", "php_phongo.c", null, PHP_MONGODB_CFLAGS);
117117
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");
118118
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");
119-
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");
119+
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");
120120
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");
121121
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");
122122
MONGODB_ADD_SOURCES("/src/libmongoc/src/common", PHP_MONGODB_COMMON_SOURCES);

php_phongo.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ PHP_MINIT_FUNCTION(mongodb) /* {{{ */
254254
php_phongo_clientencryption_init_ce(INIT_FUNC_ARGS_PASSTHRU);
255255
php_phongo_command_init_ce(INIT_FUNC_ARGS_PASSTHRU);
256256
php_phongo_cursor_init_ce(INIT_FUNC_ARGS_PASSTHRU);
257-
php_phongo_cursorid_init_ce(INIT_FUNC_ARGS_PASSTHRU);
258257
php_phongo_manager_init_ce(INIT_FUNC_ARGS_PASSTHRU);
259258
php_phongo_query_init_ce(INIT_FUNC_ARGS_PASSTHRU);
260259
php_phongo_readconcern_init_ce(INIT_FUNC_ARGS_PASSTHRU);

src/MongoDB/Cursor.c

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,6 @@ static int php_phongo_cursor_to_array_apply(zend_object_iterator* iter, void* pu
115115
return ZEND_HASH_APPLY_KEEP;
116116
}
117117

118-
static void php_phongo_cursor_id_new_from_id(zval* object, int64_t cursorid)
119-
{
120-
php_phongo_cursorid_t* intern;
121-
122-
object_init_ex(object, php_phongo_cursorid_ce);
123-
124-
intern = Z_CURSORID_OBJ_P(object);
125-
intern->id = cursorid;
126-
intern->initialized = true;
127-
}
128-
129118
/* Returns an array of all result documents for this cursor */
130119
static PHP_METHOD(MongoDB_Driver_Cursor, toArray)
131120
{
@@ -143,22 +132,12 @@ static PHP_METHOD(MongoDB_Driver_Cursor, toArray)
143132
static PHP_METHOD(MongoDB_Driver_Cursor, getId)
144133
{
145134
php_phongo_cursor_t* intern;
146-
zend_bool asInt64 = false;
147135

148136
intern = Z_CURSOR_OBJ_P(getThis());
149137

150-
PHONGO_PARSE_PARAMETERS_START(0, 1)
151-
Z_PARAM_OPTIONAL
152-
Z_PARAM_BOOL(asInt64)
153-
PHONGO_PARSE_PARAMETERS_END();
154-
155-
if (asInt64) {
156-
phongo_int64_new(return_value, mongoc_cursor_get_id(intern->cursor));
157-
} else {
158-
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.");
138+
PHONGO_PARSE_PARAMETERS_NONE();
159139

160-
php_phongo_cursor_id_new_from_id(return_value, mongoc_cursor_get_id(intern->cursor));
161-
}
140+
phongo_int64_new(return_value, mongoc_cursor_get_id(intern->cursor));
162141
}
163142

164143
/* Returns the Server object to which this cursor is attached */

src/MongoDB/Cursor.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final private function __construct() {}
1414

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

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

1919
final public function getServer(): Server {}
2020

src/MongoDB/CursorId.c

Lines changed: 0 additions & 249 deletions
This file was deleted.

src/MongoDB/CursorId.stub.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)