Skip to content

Commit

Permalink
Merge branch 'v2.x' into merge-v1.x-into-v2.x-1738334785930
Browse files Browse the repository at this point in the history
  • Loading branch information
jmikola committed Jan 31, 2025
2 parents 65bbd1b + cd3593b commit 37f7f9a
Show file tree
Hide file tree
Showing 343 changed files with 1,001 additions and 11,885 deletions.
49 changes: 49 additions & 0 deletions UPGRADE-2.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
UPGRADE FROM 1.x to 2.0
=======================

* The `getServer()` method has been removed from the CommandFailedEvent,
CommandStartedEvent, and CommandSucceededEvent event classes. The `getHost()`
and `getPort()` methods have been added in its place.
* The BSON functions in the `MongoDB\BSON` namespace have been removed in favor
of the `MongoDB\BSON\Document` class.
* The constants `MongoDB\Driver\ClientEncryption::ALGORITHM_RANGE_PREVIEW` and
`MongoDB\Driver\ClientEncryption::QUERY_TYPE_RANGE_PREVIEW` have been
removed. Use the `ALGORITHM_RANGE` and `QUERY_TYPE_RANGE` instead.
* The `MongoDB\Driver\ReadPreference` class now requires a string value for its
constructor's `$mode` parameter. The integer constants for modes have been
removed along with the `getMode()` method. Use the string constants and
`getModeString()` instead.
* All tentative return types defined in interface and non-final classes are now
fixed and are required in implementing or extending classes.
* `MongoDB\Driver\CursorInterface` now extends `Iterator`, requiring
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.
* The `--with-libbson` and `--with-libmongoc` configure options have been
removed. Use `--with-mongodb-system-libs` instead.
* All classes that previously implemented the `Serializable` interface no
longer implement this interface.
* The constructor of `MongoDB\BSON\UTCDateTime` no longer accepts a `string` or
`float` argument. To pass 64-bit integers on 32-bit platforms, use the
`MongoDB\BSON\Int64` class instead.
* The `--with-openssl-dir` configure option has been removed. If using OpenSSL,
ensure that it is detected by `pkg-config`.
* The `--with-system-ciphers` configure option has been removed. Use
`--enable-mongodb-crypto-system-profile` instead.
* `MongoDB\Driver\Query` removes the following options: `partial` (use
`allowPartialResults` instead), `maxScan`, `modifiers` (use alternative
top-level options instead), `oplogReplay`, and `snapshot`. Support for
negative `limit` values has been removed (use `singleBatch` instead).
* The `MongoDB\Driver\Manager` constructor now throws if the URI options array
includes a non-boolean value for an option expecting a boolean. This behavior
is now consistent with validation for other option types.
* Removed the following driver options from `MongoDB\Driver\Manager`:
`allow_invalid_hostname` (use `tlsAllowInvalidHostnames` URI option instead),
`ca_file` (use `tlsCAFile`), `context`,
`pem_file` (use `tlsCertificateKeyFile`),
`pem_pwd` (use `tlsCertificateKeyFilePassword`), and
`weak_cert_validation` (use `tlsAllowInvalidCertificates`).
22 changes: 22 additions & 0 deletions bin/update-release-version.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function usage()
to-stable: Mark the current version as stable
to-next-patch-dev: Update to the next patch development version
to-next-minor-dev: Update to the next minor development version
to-next-major-dev: Update to the next major development version
get-version: Print the current version number
EOT;
Expand Down Expand Up @@ -167,6 +168,23 @@ function get_next_minor_version(array $versions): array
];
}

function get_next_major_version(array $versions): array
{
$versionComponents = $versions['versionComponents'];

// Increase major version, set other components to 0
$versionComponents[0] += 1;
$versionComponents[1] = 0;
$versionComponents[2] = 0;
$versionComponents[3] = 0;

return [
'version' => get_version_string_from_components($versionComponents) . 'dev',
'stability' => 'devel',
'versionComponents' => $versionComponents,
];
}

function get_next_release_version(array $versions, string $releaseVersion): array
{
$releaseVersion = parse_release_version($releaseVersion);
Expand Down Expand Up @@ -244,6 +262,10 @@ function get_next_dev_version(array $versions): array
$newVersion = get_next_minor_version($currentVersion);
break;

case 'to-next-major-dev':
$newVersion = get_next_major_version($currentVersion);
break;

default:
usage();
}
Expand Down
40 changes: 0 additions & 40 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,10 @@ if test "$PHP_MONGODB" != "no"; then
src/BSON/Unserializable.c \
src/BSON/UTCDateTime.c \
src/BSON/UTCDateTimeInterface.c \
src/BSON/functions.c \
src/MongoDB/BulkWrite.c \
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 All @@ -198,9 +196,7 @@ if test "$PHP_MONGODB" != "no"; then
src/MongoDB/Exception/LogicException.c \
src/MongoDB/Exception/RuntimeException.c \
src/MongoDB/Exception/ServerException.c \
src/MongoDB/Exception/SSLConnectionException.c \
src/MongoDB/Exception/UnexpectedValueException.c \
src/MongoDB/Exception/WriteException.c \
src/MongoDB/Monitoring/CommandFailedEvent.c \
src/MongoDB/Monitoring/CommandStartedEvent.c \
src/MongoDB/Monitoring/CommandSubscriber.c \
Expand Down Expand Up @@ -228,22 +224,6 @@ if test "$PHP_MONGODB" != "no"; then
[no])
PHP_MONGODB_VALIDATE_ARG([PHP_MONGODB_SYSTEM_LIBS], [yes no])

PHP_ARG_WITH([libbson],
[whether to use system libbson],
[AS_HELP_STRING([--with-libbson=@<:@yes/no@:>@],
[MongoDB: Use system libbson (deprecated for --with-mongodb-system-libs) [default=no]])],
[no],
[no])
PHP_MONGODB_VALIDATE_ARG([PHP_LIBBSON], [yes no])

PHP_ARG_WITH([libmongoc],
[whether to use system libmongoc],
[AS_HELP_STRING([--with-libmongoc=@<:@yes/no@:>@],
[MongoDB: Use system libmongoc (deprecated for --with-mongodb-system-libs) [default=no]])],
[no],
[no])
PHP_MONGODB_VALIDATE_ARG([PHP_LIBMONGOC], [yes no])

PHP_ARG_WITH([mongodb-client-side-encryption],
[whether to enable client-side encryption],
[AS_HELP_STRING([--with-mongodb-client-side-encryption=@<:@auto/yes/no@:>@],
Expand All @@ -252,26 +232,6 @@ if test "$PHP_MONGODB" != "no"; then
[no])
PHP_MONGODB_VALIDATE_ARG([PHP_MONGODB_CLIENT_SIDE_ENCRYPTION], [auto yes no])

if test "$PHP_LIBBSON" != "no"; then
AC_MSG_WARN(Using --with-libbson is deprecated and will be removed in a future version. Please use --with-system-libs instead)

if test "$PHP_LIBMONGOC" = "no"; then
AC_MSG_ERROR(Cannot use system libbson and bundled libmongoc)
fi

PHP_MONGODB_SYSTEM_LIBS="yes"
fi

if test "$PHP_LIBMONGOC" != "no"; then
AC_MSG_WARN(Using --with-libmongoc is deprecated and will be removed in a future version. Please use --with-system-libs instead)

if test "$PHP_LIBBSON" = "no"; then
AC_MSG_ERROR(Cannot use system libmongoc and bundled libbson)
fi

PHP_MONGODB_SYSTEM_LIBS="yes"
fi

PHP_MONGODB_BSON_VERSION_STRING="None"
PHP_MONGODB_MONGOC_VERSION_STRING="None"
PHP_MONGODB_MONGOCRYPT_VERSION_STRING="None"
Expand Down
6 changes: 3 additions & 3 deletions config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ if (PHP_MONGODB != "no") {

EXTENSION("mongodb", "php_phongo.c", null, PHP_MONGODB_CFLAGS);
MONGODB_ADD_SOURCES("/src", "phongo_apm.c phongo_atomic.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 functions.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/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/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 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 UnexpectedValueException.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/src", PHP_MONGODB_COMMON_SOURCES);
MONGODB_ADD_SOURCES("/src/libmongoc/src/libbson/src/bson", PHP_MONGODB_BSON_SOURCES);
Expand Down
4 changes: 2 additions & 2 deletions phongo_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
* publishing a release. */

/* clang-format off */
#define PHP_MONGODB_VERSION "1.21.0dev"
#define PHP_MONGODB_VERSION "2.0.0dev"
#define PHP_MONGODB_STABILITY "devel"
#define PHP_MONGODB_VERSION_DESC 1,21,0,0
#define PHP_MONGODB_VERSION_DESC 2,0,0,0
/* clang-format on */

#endif /* PHONGO_VERSION_H */
3 changes: 0 additions & 3 deletions php_phongo.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,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 All @@ -275,7 +274,6 @@ PHP_MINIT_FUNCTION(mongodb) /* {{{ */
php_phongo_runtimeexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
php_phongo_serverexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
php_phongo_connectionexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
php_phongo_writeexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);

php_phongo_authenticationexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
php_phongo_bulkwriteexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
Expand All @@ -285,7 +283,6 @@ PHP_MINIT_FUNCTION(mongodb) /* {{{ */
php_phongo_executiontimeoutexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
php_phongo_invalidargumentexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
php_phongo_logicexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
php_phongo_sslconnectionexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);
php_phongo_unexpectedvalueexception_init_ce(INIT_FUNC_ARGS_PASSTHRU);

/* Register base APM classes first */
Expand Down
41 changes: 4 additions & 37 deletions scripts/autotools/libmongoc/CheckSSL.m4
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@ fi

PHP_MONGODB_VALIDATE_ARG([PHP_MONGODB_SSL], [auto openssl libressl darwin no])

PHP_ARG_WITH([openssl-dir],
[deprecated option for OpenSSL library path],
[AS_HELP_STRING([--with-openssl-dir=@<:@auto/DIR@:>@],
[MongoDB: OpenSSL library path (deprecated for pkg-config) [default=auto]])],
[auto],
[no])

if test "$PHP_OPENSSL_DIR" != "auto"; then
AC_MSG_WARN([Using --with-openssl-dir is deprecated and will be removed in a future version.])
fi

AS_IF([test "$PHP_MONGODB_SSL" = "openssl" -o "$PHP_MONGODB_SSL" = "auto"],[
found_openssl="no"
Expand All @@ -54,13 +43,10 @@ AS_IF([test "$PHP_MONGODB_SSL" = "openssl" -o "$PHP_MONGODB_SSL" = "auto"],[
unset OPENSSL_INCDIR
unset OPENSSL_LIBDIR
dnl Use a list of directories from PHP_SETUP_OPENSSL by default.
dnl Support documented "auto" and older, undocumented "yes" options
if test "$PHP_OPENSSL_DIR" = "auto" -o "$PHP_OPENSSL_DIR" = "yes"; then
PHP_OPENSSL_DIR="/usr/local/ssl /usr/local /usr /usr/local/openssl"
fi
dnl Use a list of directories from PHP_SETUP_OPENSSL by default.
OPENSSL_SEARCH_PATHS="/usr/local/ssl /usr/local /usr /usr/local/openssl"
for i in $PHP_OPENSSL_DIR; do
for i in $OPENSSL_SEARCH_PATHS; do
if test -r $i/include/openssl/evp.h; then
OPENSSL_INCDIR="$i/include"
fi
Expand All @@ -80,7 +66,6 @@ AS_IF([test "$PHP_MONGODB_SSL" = "openssl" -o "$PHP_MONGODB_SSL" = "auto"],[
[have_crypto_lib="no"],
[$OPENSSL_LIBDIR_LDFLAG])
dnl Check whether OpenSSL >= 1.1.0 is available
PHP_CHECK_LIBRARY([ssl],
[OPENSSL_init_ssl],
Expand Down Expand Up @@ -244,25 +229,7 @@ PHP_ARG_ENABLE([mongodb-crypto-system-profile],
[no])
PHP_MONGODB_VALIDATE_ARG([PHP_MONGODB_CRYPTO_SYSTEM_PROFILE], [yes no])

PHP_ARG_WITH([system-ciphers],
[deprecated option for whether to use system crypto profile],
AS_HELP_STRING([--enable-system-ciphers],
[MongoDB: whether to use system crypto profile (deprecated for --enable-mongodb-crypto-system-profile) [default=no]]),
[no],
[no])

dnl Do not validate PHP_SYSTEM_CIPHERS for static builds, since it is also used
dnl by the OpenSSL extension, which checks for values other than "no".
if test "$ext_shared" = "yes"; then
PHP_MONGODB_VALIDATE_ARG([PHP_SYSTEM_CIPHERS], [yes no])

if test "$PHP_SYSTEM_CIPHERS" != "no"; then
AC_MSG_WARN([Using --enable-system-ciphers is deprecated and will be removed in a future version. Please use --enable-mongodb-crypto-system-profile instead])
fi
fi

dnl Also consider the deprecated --enable-system-ciphers option
if test "$PHP_MONGODB_CRYPTO_SYSTEM_PROFILE" = "yes" -o "$PHP_SYSTEM_CIPHERS" = "yes"; then
if test "$PHP_MONGODB_CRYPTO_SYSTEM_PROFILE" = "yes"; then
if test "$PHP_MONGODB_SSL" = "openssl"; then
AC_SUBST(MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE, 1)
else
Expand Down
58 changes: 1 addition & 57 deletions src/BSON/Binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
*/

#include <php.h>
#include <zend_smart_str.h>
#include <ext/standard/base64.h>
#include <ext/standard/php_var.h>
#include <Zend/zend_interfaces.h>

#include "php_phongo.h"
Expand Down Expand Up @@ -184,60 +182,6 @@ static PHP_METHOD(MongoDB_BSON_Binary, jsonSerialize)
ADD_ASSOC_STRINGL(return_value, "$type", type, type_len);
}

static PHP_METHOD(MongoDB_BSON_Binary, serialize)
{
php_phongo_binary_t* intern;
zval retval;
php_serialize_data_t var_hash;
smart_str buf = { 0 };

intern = Z_BINARY_OBJ_P(getThis());

PHONGO_PARSE_PARAMETERS_NONE();

array_init_size(&retval, 2);
ADD_ASSOC_STRINGL(&retval, "data", intern->data, intern->data_len);
ADD_ASSOC_LONG_EX(&retval, "type", intern->type);

PHP_VAR_SERIALIZE_INIT(var_hash);
php_var_serialize(&buf, &retval, &var_hash);
smart_str_0(&buf);
PHP_VAR_SERIALIZE_DESTROY(var_hash);

PHONGO_RETVAL_SMART_STR(buf);

smart_str_free(&buf);
zval_ptr_dtor(&retval);
}

static PHP_METHOD(MongoDB_BSON_Binary, unserialize)
{
php_phongo_binary_t* intern;
char* serialized;
size_t serialized_len;
zval props;
php_unserialize_data_t var_hash;

intern = Z_BINARY_OBJ_P(getThis());

PHONGO_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_STRING(serialized, serialized_len)
PHONGO_PARSE_PARAMETERS_END();

PHP_VAR_UNSERIALIZE_INIT(var_hash);
if (!php_var_unserialize(&props, (const unsigned char**) &serialized, (unsigned char*) serialized + serialized_len, &var_hash)) {
zval_ptr_dtor(&props);
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE, "%s unserialization failed", ZSTR_VAL(php_phongo_binary_ce->name));

PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
return;
}
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);

php_phongo_binary_init_from_hash(intern, HASH_OF(&props));
zval_ptr_dtor(&props);
}

static PHP_METHOD(MongoDB_BSON_Binary, __serialize)
{
PHONGO_PARSE_PARAMETERS_NONE();
Expand Down Expand Up @@ -339,7 +283,7 @@ static HashTable* php_phongo_binary_get_properties(zend_object* object)

void php_phongo_binary_init_ce(INIT_FUNC_ARGS)
{
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);
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);
php_phongo_binary_ce->create_object = php_phongo_binary_create_object;

memcpy(&php_phongo_handler_binary, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
Expand Down
6 changes: 1 addition & 5 deletions src/BSON/Binary.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace MongoDB\BSON;

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

final public function __toString(): string {}

final public function serialize(): string {}

final public function unserialize(string $data): void {}

final public function __unserialize(array $data): void {}

final public function __serialize(): array {}
Expand Down
2 changes: 0 additions & 2 deletions src/BSON/BinaryInterface.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@

interface BinaryInterface
{
/** @tentative-return-type */
public function getData(): string;

/** @tentative-return-type */
public function getType(): int;

public function __toString(): string;
Expand Down
Loading

0 comments on commit 37f7f9a

Please sign in to comment.