Commit Graph

302 Commits

Author SHA1 Message Date
Andreas Braun
18901bbe1c Update libmongoc and libmongocrypt (#1398)
* Update to latest libmongoc dev version

* Update to latest libmongocrypt dev version
2023-01-12 09:23:16 +01:00
Jeremy Mikola
1650a911dd PHPC-2174: Bump libmongocrypt to 1.6.2 (#1394) 2022-12-27 23:04:58 -05:00
Andreas Braun
a237193eca BSON class implementations (#1387)
* Extract bson to json conversion logic

* PHPC-326: Add class to represent raw BSON document

* PHPC-326: Add class to represent raw BSON array

* Typemaps now support raw BSON type

* Short-circuit encoding of BSON zvals

* PHPC-324: Add BSONIterator class

* Polyfill zend_array_is_list on PHP < 8.1

* Add offset accessors to BSON classes

* Add more tests around iterators and fetching offsets

* Remove compare handler for BSONIterator

* Rename BSONArray to ArrayList

* Rename BSONDocument to Document

* Rename BSONIterator to Iterator

* Implement Document::fromBSONString

* Test BSON document in bson-corpus tests

* Fix ArrayList handling of BSON arrays with wrong keys

* Address code review for bson-corpus tests

* Address code review in ArrayList

* Address code review for Document

* Address code review for Iterator

* Allow BSON iterators to be rewound

* Address code review in tests

* Fix comment explaining php_phongo_bson_append_object

* Remove obsolete php_phongo_bson_append_zval

* More review changes to tests

* Return base64 encoded data when debugging BSON classes

* Allow serialisation of Document and ArrayList

* Add test for iterating past the end of a structure

* Update exception message to contain class name

* Make BSON pclass handling test more complete

* Fix wrong handling of type map in nested structures

* Ensure objects are backed by actual memory

* Validate UTF-8 BSON data before returning it

* Allow ArrayList::toPHP() to accept a different root type map

* Ignore null return type for invalid BSON iterators on PHP < 8

* Throw when calling get on non-existing BSON offsets

* Remove unnecessary length from serialised output

* Refactor names around type map handling

* Use short array syntax in new tests

* Improve test descriptions

* Restructure BSON iterator tests

* Expand BSON class serialisation tests

* Throw exception when iterator is exhausted

The previous method relied on the type system of PHP to throw an exception when accessing the key of an exhausted iterator, but this does not work on non-debug versions of PHP.

* Update test description

* Rename ArrayList class to PackedArray
2022-12-16 08:48:09 +01:00
Jeremy Mikola
6a7a2ba546 Bump to libmongoc to 1.24-dev (#1388)
* Update expected output for libmongoc 1.24-dev

See mongodb/mongo-c-driver@40a64c2ffd

* Require C99 when compiling
2022-11-30 03:06:12 -05:00
Jeremy Mikola
b83ab98376 PHPC-2166: Add -Wstrict-prototypes dev build flag and fix decl (#1382) 2022-11-14 10:43:33 -05:00
Jeremy Mikola
594cad9a30 PHPC-2083: Revise BSON handling of enum classes
Revert previous enum instantiation behavior and PersistableEnum trait from de5f1e5a93

Backed enums will be encoded as their case value. Non-backed cannot be encoded and no enums can be encoded at the root level.

Prohibit enums from implementing Persistable and Unserializable.
2022-11-10 20:21:36 +08:00
Andreas Braun
ae18d5ccab Bump to libmongoc 1.23.1 (#1377) 2022-10-21 13:11:07 +02:00
Remi Collet
d495e1eb91 protect message to allow comma (#1375) 2022-10-21 12:55:33 +02:00
Jeremy Mikola
dadb93fb34 Merge branch 'v1.14'
v1.14 pointed to libmongoc 1.14.2, which was released some time after the submodule target in the master branch (a dev commit before libmongoc 1.23.0). To resolve this conflict, the libmongoc submodule has been bumped to 1.23.0.

Note: a libmongoc 1.23.1 tag also exists, but that bump can be done in a subsequent PHPC ticket related to the libmongoc changes therein.

This also adds a section to CONTRIBUTING.md to provide guidance on resolving submodule merge conflicts.
2022-10-20 21:44:20 +08:00
Jeremy Mikola
e853c4c0e6 PHPC-2157: Bump pkg-config requirement and libmongoc-version matrix to 1.22.2
This was missed in 0a23d0a94b
2022-10-20 20:51:55 +08:00
Jeremy Mikola
5c0b2c4f04 Merge branch 'v1.14' 2022-09-09 16:01:06 -04:00
Jeremy Mikola
6a7edac1f1 PHPC-2137: Upgrade libmongoc to 1.22.1 and libmongocrypt to 1.5.2 (#1358) 2022-09-08 19:31:27 -04:00
Jeremy Mikola
de5f1e5a93 PHPC-2083: Allow enums to be instantiated during BSON decoding (#1317)
Enums serialize like PHP objects with a "name" property (BackedEnum instance will also have a "value") and thus become BSON documents. In order for a document to unserialize back to an enum, it must implement either Unserializable or Persistable. The bsonUnserialize() method serves no purpose for initialization, but it will still be invoked.

This introduces a PersistableEnum trait, which can be used for both Unserializable or Persistable implementations.

Co-authored-by: Sara Golemon <pollita@php.net>
2022-08-25 23:09:45 -04:00
Andreas Braun
6887226d34 PHPC-1709: Add typing information to arginfo (#1337)
* Add missing macros for declaring arguments

* Add macros to define disabled constructor and __wakeup

* Define arginfo via stubs for BSON classes

* Declare tentative return types in interfaces

* Add correct return type for __set_state methods

* Generate class entries for BSON classes

* Declare Binary class constants in stub file

* Use stubs in exception classes

* Add stubs for monitoring classes

* Fix wrong JsonSerializable class in BSON stubs

* Disable declaration-after-statement

This is necessary to let the generated arginfo files compile

* Use stubs for driver classes

* Fix deprecation messages in tests

* Add missing macro

* Fix tests relying on value injection

* Parse parameters in disabled constructor/wakup function

* Add note about arginfo files to contribution docs

* Add GitHub action to check generated arginfo files

* PHPC-2115: Use DateTimeInterface in UTCDateTime constructor signature

* Don't install mongodb extension in GitHub actions workflows

* Change indentation in stub files

* Use individual #if conditions for each stub method

* Make disabled constructor/wakeup methods static

* Fix bulkWrite parameter name

* Use %d to match property count in tests

* Ensure all classes with disabled serialisation declare __wakeup
2022-08-03 08:42:07 +02:00
Jeremy Mikola
63540009f7 PHPC-2104: ClientEncryption::QUERY_TYPE_EQUALITY is a string (#1334)
* Define additional constants in mongocrypt-export.h

* PHPC-2104: ClientEncryption::QUERY_TYPE_EQUALITY is a string

Downstream change since MONGOC_ENCRYPT_QUERY_TYPE_EQUALITY was changed to a string type.

Bumps libmongocrypt submodule to 1.5.0-rc2. Related to this bump, mongocrypt.h is no longer generated.

Bumps libmongoc submodule to 1.22-dev.
2022-06-24 14:59:17 -04:00
Jeremy Mikola
db4fe3dc8b PHPC-2049: BulkWrite and Query support comment option of any type (#1320)
* PHPC-2049: Bump libmongoc and libmongocrypt submodules

libmongoc master (1.22-dev) now depends on libmongocrypt master (1.5-dev).

libmongoc's bundled zlib library was updated to 1.2.12.

* PHPC-2049: BulkWrite and Query support comment option of any type

MongoDB 4.4+ allows a comment option of any type on most commands. Previously, find required a string type and write commands did not support comment at all. The driver does not validate the option and relies on the server to raise an error.

* Fix title and variable access in BulkWrite and Query let option tests

* Fix grammar in php_phongo_bulkwrite_delete_apply_options comment

* Undefine additional Query option macros
2022-05-20 11:11:18 -04:00
Jeremy Mikola
98727aee85 PHPC-2005: Support 'let' option for multiple CRUD commands (#1312) 2022-03-31 17:03:57 -04:00
Jeremy Mikola
82aef8fae9 PHPC-2031: Upgrade libmongoc to 1.21.1 and libmongocrypt to 1.3.2 (#1306) 2022-03-23 12:11:45 -04:00
Jeremy Mikola
1ce10adcb3 Merge branch 'v1.12' 2022-02-22 16:06:41 -05:00
Jeremy Mikola
34d4adc472 PHPC-2071: Bump pkg-config requirements for libmongoc 2022-02-22 16:03:31 -05:00
Jeremy Mikola
fc358d6f18 PHPC-2040: Break down php_phongo.c into smaller files
This also cleans up header includes throughout the project. The order follows: libbson, libmongoc, libmongocrypt, PHP, contrib (e.g. PHP array API), internal modules (e.g. php_phongo.h, phongo_bson.h), and class headers. Quoted strings are used for all but PHP includes, which are always sourced from system directories.

php_phongo.h is now responsible for including config.h and assigning the default logging domain.
2022-01-26 20:31:48 -05:00
Jeremy Mikola
10b3a1fe70 PHPC-1150: SDAM Monitoring (#1289)
* PHPC-1805: Implement ServerDescription class

* PHPC-1910: Implement Server::getServerDescription()

* PHPC-1934: Check for uninitialized intern in ServerDescription get_properties_hash

* PHPC-1925: Change ServerDescription::getType() to return a string

* PHPC-1891: Implement TopologyDescription class

* PHPC-1892: Implement SDAMSubscriber interface

* PHPC-1893: Implement SDAM event classes

* Revise server and topology event classes and tests

Use phongo_objectid_init in getTopologyId() methods. Report topologyId as an ObjectId in debug info. Report TopologyDescription servers as ServerDescription in debug info.

Copy parameters in phongo_serverdescription_init and phongo_topologydescription_init for consistency with other functions (e.g. phongo_readconcern_init). This also creates phongo_serverdescription_init_ex for when we want to skip copying in Server::getServerDescription().

* PHPC-1953: Add tests for debug handlers

* PHPC-1959: Utilize Manager::addSubscriber() in tests

Skip TopologyClosedEvent test (pending PHPC-2023)

* PHPC-1958: Assert same topologyId for SDAM events

* PHPC-2025: Support load balancer in ServerDescription and TopologyDescription

* PHPC-2026: Handle 64-bit lastUpdateTime for 32-bit platforms

Co-authored-by: Tanli Su <46271307+tanlisu@users.noreply.github.com>
Co-authored-by: Andreas Braun <git@alcaeus.org>
Co-authored-by: Tanli Su <tanli.su@gmail.com>
2022-01-10 13:14:10 -05:00
Jeremy Mikola
ab44b0cbeb PHPC-1647: Use mongoc_client_new_from_uri_with_error
This allows PHPC to defer entirely to libmongoc for cross-option URI validation

Bump libmongoc to 1.21-dev

Build changes are ported from upstream CMake changes (see: CDRIVER-4249)
2022-01-05 13:10:45 -05:00
Jeremy Mikola
f972586b4c PHPC-2012: Remove extra AX_CHECK_COMPILE_FLAG args 2021-12-15 15:25:25 -05:00
Jeremy Mikola
59298f51df PHPC-2011: Bump pkg-config requirements for libmongoc and libmongocrypt 2021-12-14 17:09:50 -05:00
Jeremy Mikola
8a4670becd PHPC-2011: Upgrade libmongoc to 1.20.0 and libmongocrypt to 1.3.0 (#1279)
* PHPC-2011: Bump libmongocrypt to 1.3.0

* PHPC-2011: Bump libmongoc to 1.20.0

* Script to update submodule sources in config.m4 and config.w32
2021-12-06 11:15:20 -05:00
Jeremy Mikola
fe99deb32a PHPC-1880: Drop support for PHP 7.1 (#1273)
* PHPC-1880: Drop support for PHP 7.1

* Bump PHP versions in AppVeyor config

* PHPC-1880: Update Evergreen config for PHP 7.2+ and MongoDB 5.0

Bump edge-versions:latest-stable to MongoDB 5.0. Drops PHP 7.1 and adds PHP 8.0 to php-versions and newly created php-edge-versions axis.

Use oldest-supported or latest-stable PHP version for matrices other than test-php-versions.

Make variant display names consistent to help detect duplicates.

Remove WiredTiger from mongo-42-storage-engines since it's tested in most other variants by default.

* Revise "cursor not found" error message assertions for latest server version

* Temporarily remove 1.19.x from libmongoc-version axis
2021-11-10 10:28:21 -05:00
Jeremy Mikola
a8a2210488 PHPC-1997: Migrate to new libbson atomic API (#1272)
* Bump libmongoc to 1.20-dev

* PHPC-1997: Migrate to new libbson atomic API
2021-11-05 14:17:17 -04:00
Jeremy Mikola
16fb5cfc92 PHPC-1993: Require 1.19.1 for libmongoc and libbson system libraries (#1269) 2021-11-02 11:24:28 -04:00
Jeremy Mikola
cfc6bbbe5d PHPC-1978: Expose mongoc_global_mock_service_id as INI option
This also consolidates INI functions (and trace logging) into a separate file and ensure that mongoc logging is disabled during GSHUTDOWN (avoiding a potential segfault).

Enable service ID mocking when testing load balancers with HAProxy.
2021-10-15 13:44:30 -04:00
Jeremy Mikola
ac4935338a PHPC-1761: Snapshot Reads (#1243)
* Bump libmongoc to 1.19-dev

* PHPC-1890: Constant for ReadConcern snapshot level

* Move Manager::startSession() error test and delete obsolete test

The deleted error test was redundant. It was originally created in ca4c52eb1c to work around changes in PHP 8, but 60febd0f28 subsequently reintroduced a portable version of the test case.

Also adds missing SKIPIF to startSession test.

* PHPC-1889: Session snapshot option

* PHPC-1875: Session with snapshot=true cannot perform writes

* PHPC-1876: Session with snapshot=true requires MongoDB 5.0+
2021-08-04 19:11:33 -04:00
Andreas Braun
2ab8d6bac1 Drop support for PHP 7.0 (#1234) 2021-07-01 11:58:02 -04:00
Jeremy Mikola
324182a8e6 PHPC-1804: Manager::addSubscriber and removeSubscriber (#1213)
* Use zend_exception_ce instead of zend_exception_get_default()

zend_exception_get_default() has been deprecated since PHP 7.0. See: php/php-src@f9e9d3a437

* Check retval from php_phongo_set_monitoring_callbacks

This ensures that php_phongo_client_register is never called in the event this method fails (however unlikely).

* Index subscriber HashTable by numeric object handles

This also updates add/removeSubscriber to use the new argument parsing macros from deead9687e.

* PHPC-1804: Manager::addSubscriber and removeSubscriber

Implements per-client event subscribers. Moves existing APM code to a new phongo_apm.c module and adds logic to coordinate dispatching between global and per-client subscribers.
2021-04-09 08:55:44 -04:00
Andreas Braun
deead9687e PHPC-1716 Allow configuring server API version in manager (#1204)
* Introduce MongoDB\Driver\ServerApi

* Accept serverApi driver option

* Introduce create_test_manager factory to create manager

A centralised entry point is required to inject the API_VERSION env variable later.

* Add build variant to test with requireApiVersion=true

* Fix wrong configuration for auth variable

This changed when migrating from our own scripts to drivers-evergreen-tools and was not updated properly, causing all tests to run with auth disabled.

* Declare ZEND_PARSE_PARAMETERS_NONE macro

This macro is missing on PHP < 7.3

* Remove duplicated API param storage

* Add missing semicolons

* Add ZEND_PARSE_PARAMETERS_NON_EX macro

* Extract error handling functionality to separate macros

* Throw if internal mongoc_server_api_t is already initialised

* Use imported namespaces in tools file

* Fix type info for reflection

* Use American English spelling

* Only use typed serialize signature on PHP 8+

* Update PHONGO_PARSE_PARAMETERS_NONE macro for PHP < 7.3

* Remove usage of ZEND_STRL within zend_hash_str_add

This causes compile failures on PHP < 7.3 that I have yet to understand.

* Fix errors in new PHONGO_PARSE_PARAMETERS macros
2021-03-26 15:43:48 +01:00
Andreas Braun
9f854a43f7 PHPC-1681 Support parsing $uuid as extended JSON representation for subtype 4 binary (#1208)
* Update to latest version of libmongoc

* Support parse error tests for binary types

* Sync bson-corpus spec tests for binary
2021-03-26 10:04:18 +01:00
Andreas Braun
fa45c5452c Update libmongoc to latest version (#1205) 2021-03-18 10:09:43 +01:00
Andreas Braun
23714f8e19 PHPC-1684 Support Azure and GCP for FLE keystores (#1196)
* Update to latest libmongoc dev version

* Update to libmongocrypt 1.2.1-dev
2021-02-09 11:18:03 +01:00
Andreas Braun
d785d5e15e PHPC-1689: Allow driver to compile with PHP 8
* PHPC-1689: Remove remainder of TSRMLS_* macros
* PHPC-1689: Add compatibility macro for PHP 8 object change
* PHPC-1689: Replace PHP_CHECK_GCC_ARG with AX_CHECK_COMPILE_FLAG
* PHPC-1689: phongo_compat_object_handler_type and macros
* PHPC-1689: clone_object handlers
* PHPC-1689: compare_object handlers
* PHPC-1689: replace zend_hash_init_ex with zend_hash_init
* PHPC-1689: get_debug_info and get_properties handlers
2020-10-13 15:24:02 +02:00
Andreas Braun
7274d497c1 Bump libmongoc to latest version (#1152)
* PHPC-1420: Fix stack smashing when using mixed replica set config

* Support new debug assertion switch for libmongoc

* Only set MONGOC_ENABLE_DEBUG_ASSERTIONS when compiling against bundled libs
2020-07-28 20:44:02 +02:00
Andreas Braun
be630dcbe4 PHPC-479: Print library version for libmongoc, libbson, and libmongocrypt (#1153) 2020-07-28 09:58:43 +02:00
Jeremy Mikola
2073946849 Bump libmongoc to 1.17.0-rc0
Test change to use session with command to ensure it is pooled
2020-07-15 11:59:44 -04:00
Jeremy Mikola
44c40e10ce PHPC-1632: Bump libmongoc for keepalive changes 2020-06-04 10:32:49 -04:00
Andreas Braun
d6f307209d Update to latest libmongoc 1.17 version 2020-05-30 17:04:05 +02:00
Andreas Braun
083517bfee Bump to latest libmongoc version 2020-05-20 14:31:24 +02:00
Jeremy Mikola
e9fa2c6223 PHPC-1621: Bump libmongocrypt to 1.0.4 2020-05-13 16:13:06 -04:00
Andreas Braun
b6fed721c5 PHPC-1483: Enable MONGODB-AWS auth in libmongoc 2020-03-09 13:07:13 +01:00
Andreas Braun
a22f49f989 Only enable kms-message support if an SSL library was found 2020-03-09 11:55:56 +01:00
Andreas Braun
9ac6f237b0 Update to latest libmongoc version 2020-02-28 08:20:25 +01:00
Andreas Braun
656cd076db Merge branch 'v1.7'
* v1.7:
  PHPC-1560: Fix compilation with bundled libmongocrypt for non-standard openssl directories
2020-02-27 10:06:13 +01:00
Andreas Braun
1d33e14923 PHPC-1560: Fix compilation with bundled libmongocrypt for non-standard openssl directories 2020-02-26 14:34:35 +01:00