Commit Graph

172 Commits

Author SHA1 Message Date
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
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
57f8068f32 PHPC-2152: Link libresolv when detecting res_nsearch (#1371)
This fixes a bug inadvertently introduced in b581f2a3e4.
2022-10-18 22:25:43 -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
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
91a1585db1 Remove _DARWIN_C_SOURCE definition for bundled sources on macOS
Reverts a change introduced in ab44b0cbeb. This was previously in mongodb/mongo-c-driver#920 but removed before merging in mongodb/mongo-c-driver@9d2d8b157c.
2022-01-05 15:50:21 -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
968958fe46 PHPC-2019: Remove Solaris checks in m4 build scripts
libmongoc removed Solaris support in version 1.8.0 so there is no reason to retain these checks.
2022-01-05 13:10:45 -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
e2ba4103d5 PHPC-1918: Update Javascript and Symbol BSON corpus tests (#1256)
Synced with mongodb/specifications@c4cc034e29
2021-08-26 10:57:36 -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
ed31cba5cb PHPC-1739 Move from travis-ci to GitHub Actions (#1199)
* Add GitHub Action workflow for tests

* Add workflow to check formatting

* Remove travis-ci config

* Fix clang-format error

* Add shared json extension for tests

* Hide output for xfail tests

* Use mongo-orchestration configs from drivers-evergreen-tools

* Drop obsolete test scripts

This drops the legacy VM environment and remnants of the travis-ci config

* Remove obsolete server_id config

* Add note about MONGO_ORCHESTRATION_URI to contribution docs

* Restore previous XFAIL behaviour

This did not have the expected effect of preventing diff output for tests that expect failures, so it can be reverted.

* Make SSL certificate path configurable for tests

Since mongo-orchestration will always bring its own certificates, we need to set the correct SSL certificate directory for our tests. This is skipped on GitHub Actions as we don't test SSL builds there (yet). If SSL_DIR was not set, tests requiring SSL will be skipped.

* Fix code review nits
2021-02-23 14:49:54 +01:00
Calvin Buckley
b581f2a3e4 PHPC-1706: Don't try linking against libresolv on AIX (#1172)
On AIX, the resolver functions are in libc, so trying libresolv
will cause the checks to fail. The behaviour should be instead
like AC_SEARCH_LIBS.

This hardcodes a check not to use libresolv on AIX. Better than
nothing, but it may not compensate for other systems without a
libresolv.
2020-11-24 10:47:31 +01:00
Andreas Braun
c07159a3c5 Merge branch 'v1.8'
* v1.8:
  Fix wrong assignment of MONGOC_HAVE_SS_FAMILY (#1169)
2020-10-22 14:36:35 +02:00
Andreas Braun
9e9acf427c Fix wrong assignment of MONGOC_HAVE_SS_FAMILY (#1169) 2020-10-22 14:34:55 +02:00
Jeremy Mikola
c81330c077 Remove trailing space in generated comments 2020-07-23 11:36:09 -04:00
Jeremy Mikola
96f97f8d43 PHPC-1653: Resync BSON corpus spec tests
Syncs tests with mongodb/specifications@1713439515. Includes tests for PHPC-1655 and PHPC-1652.

Adds logic to canonicalize $numberDouble values, which allows previously skipped tests to pass. This was noticed because SPEC-1537 changed the description of these tests and they were no loner skipped by convert-bson-corpus-tests.php.
2020-07-23 11:36:09 -04:00
Andreas Braun
5e750a86b2 PHPC-1533: Add first OCSP test 2020-05-19 20:21:51 +02:00
Jeremy Mikola
d97a66a545 PHPC-1313: Support Zstandard compression 2020-05-13 10:56:14 -04:00
Andreas Braun
9ac6f237b0 Update to latest libmongoc version 2020-02-28 08:20:25 +01:00
Andreas Braun
7cea21a25a PHPC-1496: Add support for compiling with libmongocrypt 2020-01-08 12:41:41 +01:00
Andreas Braun
6abb38feb7 Update to latest libmongoc version 2019-12-19 15:38:04 +01:00
Andreas Braun
5fd52869e2 PHPC-889: Validate Javascript scope on BSON decoding 2019-10-25 11:25:28 +02:00
Andreas Braun
201acd92f4 PHPC-1290: Update sharded test clusters to have multiple mongoses
This is necessary because session pinning doesn't work when connected to a single mongos node
2019-08-28 20:10:47 +02:00
Andreas Braun
ea7489bf72 PHPC-1369: Update libmongoc to latest 1.15-dev 2019-08-12 07:49:29 +02:00
Andreas Braun
5ea668e0b9 PHPC-1320: Regenerate test certificates with SHA256 signatures 2019-07-30 11:07:23 +02:00
Jeremy Mikola
d145409286 PHPC-1364: Upgrade libmongoc to 1.14.0
Per src/libmongoc/doc/installing.rst, the VERSION_CURRENT and VERSION_RELEASED files must now be generated. This requires Python and the GitPython pip module to run src/libmongoc/build/calc_release_version.py. A new libmongoc-version-current Makefile target has been added.
2019-05-01 13:42:38 -04:00
Jeremy Mikola
8dabad6016 Use sslAllowConnectionsWithoutCertificates for STANDALONE_SSL
This option was introduced in 3.0 and supersedes sslWeakCertificateValidation.
2019-02-27 20:02:19 -05:00
Jeremy Mikola
7add0373ee Remove sslAllowInvalidHostnames from STANDALONE_SSL params
sslWeakCertificateValidation is more permissive, so this may be redundant. MO's own configurations don't specify this for SSL environments.
2019-02-27 20:02:19 -05:00
Derick Rethans
5eb09774a7 PHPC-864: Add storage engines to Evergreen matrix 2019-02-14 15:35:31 -05:00
Derick Rethans
55a9c8f2c3 PHPC-1180: Renew SSL certificates 2019-02-14 15:35:31 -05:00
Derick Rethans
768882dd3a PHPC-1240: Remove nssize and smallfiles 2019-02-14 15:35:31 -05:00
Derick Rethans
f98873ba92 Don't set the dbpath 2019-02-14 15:35:31 -05:00
Derick Rethans
f08b94b282 Replace directory env variable for SSL config settings 2019-02-14 15:35:30 -05:00
Derick Rethans
c6d6a5cfcb Don't set the dbpath at all 2019-02-14 15:35:30 -05:00
Derick Rethans
cee996bc79 Add preliminary Evergreen Config 2019-02-14 15:35:30 -05:00
Peter Kokot
644a2b355c Fix AC_CHECK_FUNC macro call syntax for rand_r()
The AC_CHECK_FUNC macro has only the following form:
AC_CHECK_FUNC(function, [action-if-found], [action-if-not-found])
In most cases adding more arguments to macro call don't cause errors,
but it also doesn't have any functionality either.
2018-10-02 13:54:32 +01:00
Derick Rethans
897c3f5b4b Merge branch 'v1.5' 2018-08-30 11:45:37 +01:00
Derick Rethans
9a27390d4e PHPC-1184: Added replica set with auth 2018-08-30 11:44:07 +01:00
Chris Wright
79d0054abf PHPC-1241: OpenSSL 1.1 not found if pkg-config is not available 2018-08-21 12:03:12 +01:00
Derick Rethans
6563d28e50 PHPC-1184: Add replica set with single node 2018-08-08 17:11:51 +01:00
Derick Rethans
2263fd1434 PHPC-1184: Added sharded cluster with replica set shards 2018-08-07 12:29:48 +01:00
Peter Kokot
394eb79c3d Replace obsolete AC_TRY_LINK with AC_LINK_IFELSE
The AC_TRY_LINK macro has been made obsolete in Autoconf 2.50 in 2001.
It should be replaced with AC_LINK_IFELSE instead.

Systems should by now well support this, since PHP 5.3 required Autoconf
2.13+ (released in 1999) or newer, PHP 5.4 required Autoconf 2.59+
(released in 2003), and since PHP 7.2, Autoconf 2.64+ (released in 2008)
is required and for PHP 7.2 phpize the Autoconf 2.59+ is required.

Refs:
- https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/AC_005fACT_005fIFELSE-vs-AC_005fTRY_005fACT.html
- https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Obsolete-Macros.html
2018-07-24 11:11:47 +01:00
Peter Kokot
a3d806c155 Remove unused autotools macro AC_COMPILE_CHECK_SIZEOF
The AC_COMPILE_CHECK_SIZEOF is from the GNU Autoconf Archive and was
renamed to AX_COMPILE_CHECK_SIZEOF. However this macro is not used in
current MongoDB PHP extension nor in the mongo-c-driver dependency
anymore.
2018-07-24 11:09:06 +01:00
Derick Rethans
7212d65b16 Merge branch 'v1.5' 2018-07-20 16:40:02 +01:00
Derick Rethans
923b925077 PHPC-1184: Add MongoDB 3.0 replicaset to Travis 2018-07-20 16:39:37 +01:00
Peter Kokot
0d8d7be941 Replace AC_HELP_STRING with AS_HELP_STRING
The AC_HELP_STRING has been made obsolete since Autoconf 2.58 somewhere
in 2003. The new AS_HELP_STRING macro has been since recommended to be
used and should be today supported on most systems out there. The phpize
script for PHP 7.2+ requires Autoconf 2.59 and PHP requires 2.64.

This patch has been made with the help of the autoupdate script.

Autoconf changelog:
- http://git.savannah.gnu.org/cgit/autoconf.git/tree/ChangeLog.3
2018-07-20 09:02:50 +02:00
Derick Rethans
da240406d3 PHPC-1241: OpenSSL 1.1 not found if pkg-config is not available 2018-07-17 11:11:11 +01:00