Commit Graph

95 Commits

Author SHA1 Message Date
Andreas Braun
43b5499e01 PHPC-2156: Work around crypt_shared log output (#1403) 2023-02-02 10:41:13 +01: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
7423da41aa PHPC-2159: Consider enums and traits in BSON decoding instantiatable checks
Prohibit uninstantiatable classes in type maps, and ignore them when processing __pclass fields.

Utilize zend_get_object_type_case from PHP 8.2 for more helpful error messages in php_phongo_bson_state_fetch_class.
2022-11-10 20:21:36 +08: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
03fcb6b9ef PHPC-2099: crypt_shared testing (#1333)
* Use non-breaking space in OS axis labels

* Revise titles and Manager construction in autoEncryption tests

* Define CSFLE_KEY_VAULT_NS and CSFLE_LOCAL_KEY constants

The value for CSFLE_KEY_VAULT_NS is based on the example from PHPLIB-826. This was not required but helps makes all tests consistent and will make it easier if we need to add functionality to a helper to drop the key vault collection before a test.

Using CSFLE_LOCAL_KEY allows removal of a duplicated string literal in various CSFLE tests. Although the new constant wasn't required for all tests (empty strings worked fine to satisfy option validation), using a constant helps ensure consistency across the test suite.

Also use create_test_manager() in more places when basic.inc is included. The remaining instances of direct Manager construction should only be in tests where basic.inc isn't used.
2022-06-22 13:37:56 -04:00
Jeremy Mikola
93efe0aeb6 PHPC-2073: Remove references to pre-3.6 servers (#1305)
* Remove pre-3.6 server versions from Evergreen matrix

* Remove skipped tests for pre-3.6 servers

* Remove old mongo-orchestration configs and Evergreen tasks

* Remove flaky replica set tests

These tests assume a particular replica set member is always the primary, so tag assertions may fail if a different member is elected. The server-getTags-002.phpt test has more flexible assertions for replica set tags, so we can safely remove these tests.
2022-03-01 20:30:00 -05:00
Jeremy Mikola
2db00e0e24 PHPC-2064: Call skip_if_not_clean after other skip functions
"nocache" output from skip_if_not_clean may cause "skip" output from other functions to be ignored. Changing the order so that skip_if_not_clean is always called last will fix this in most cases (excluding tests that call skip_if_not_clean multiple times).
2022-02-10 13:20:52 -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
Andreas Braun
b27fa4d019 PHPC-1965 Re-enable PHP 8.1 build on GH Actions (#1258)
* Re-enable PHP 8.1 build on GH Actions

* Work around different error wording in PHP 8.1

* Limit failing tests to PHP < 8.1

* Add tests for PHPC-1839 for PHP >= 8.1
2021-09-07 08:18:08 +02: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
9c51b70e60 Merge branch 'v1.9'
* v1.9:
  Fix build failures with clang 12 (#1193)
  PHPC-1748 Fix wrong return value of Cursor::key when iterator is not valid (#1192)
2021-01-26 07:55:36 +01:00
Andreas Braun
24eb9bc37a PHPC-1748 Fix wrong return value of Cursor::key when iterator is not valid (#1192)
* PHPC-1748 Fix wrong return value of Cursor::key when iterator is not valid

* Inline single-use iterator handlers
2021-01-25 12:44:03 +01:00
Andreas Braun
032af9a8ef PHPC-1529: Reset libmongocrypt key vault client after forking (#1189)
* PHPC-1529: Reset libmongocrypt key vault client after forking

* Run ping command instead of find

* Update wrong comment

* Only run tests when libmongocrypt is present

* Add mongocryptd.pid to gitignore

* Fix test failures due to missing mongocryptd
2021-01-20 19:30:39 +01:00
Andreas Braun
9da82d3425 Merge branch 'v1.9'
* v1.9:
  PHPC-1713: Ensure Cursor::current returns null on invalid positions (#1186)
2021-01-13 11:00:09 +01:00
Jeremy Mikola
5e2f7b5461 PHPC-1645: Allow disabling of libmongoc client persistence (#1187)
* Replace client pointers on object structs with Manager references

* Request-scoped Manager registry for APM events

* Ensure Manager is registered regardless of persistent client

* Reset request-scoped clients when forking

* Test for freeing Manager during RSHUTDOWN via subscriber reference

Co-authored-by: Andreas Braun <git@alcaeus.org>
2021-01-12 08:27:32 -05:00
Andreas Braun
70a097e5a1 PHPC-1713: Ensure Cursor::current returns null on invalid positions (#1186)
* Ensure Cursor::current returns null on invalid positions

* Addressed code review feedback
2020-12-22 14:37:19 +01:00
Andreas Braun
a0be179a70 PHPC-1691: Provide Iterator implementation for cursors 2020-10-29 19:38:14 +01:00
Jeremy Mikola
ca4c52eb1c PHPC-1692: Test suite fixes for PHP 8 2020-10-13 15:24:02 +02:00
Jeremy Mikola
d4f8583da2 Remove unused variable 2020-02-03 13:13:48 +01:00
Jeremy Mikola
9ecb50a7e6 PHPC-1274: Reset client after forking for Cursor and Session
Check PID before creating/freeing a session or cursor to avoid interfering with resources owned by a parent process. Additionally, prohibit resetting a client multiple times to avoid cases where child resources may not be cleaned up.
2020-01-10 17:28:48 -05:00
Andreas Braun
183a207e24 PHPC-1419: Expose error labels from getMore responses 2019-09-02 11:27:39 +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
fa5ce78d0f Fix tests for PHP 7.4 2019-08-13 14:07:57 +02:00
Jeremy Mikola
5f235387d9 PHPC-1414: Skip tests when mongo orchestration is not available 2019-07-22 11:56:14 -04:00
Jeremy Mikola
7af437854a Revise test title 2019-02-28 18:15:09 -05:00
Derick Rethans
aadec88a07 MongoDB-latest changes error message
016+ Error on remote shard localhost:4400 :: caused by :: collection dropped. UUID d65ff43a-d974-4cbd-b248-68652d7c826b
016- %Scollection dropped between getMore calls
2019-02-14 15:35:31 -05:00
Derick Rethans
bcbdcbfebf These tests are >= 3.6, as they use changeStreams 2019-02-14 15:35:31 -05:00
Derick Rethans
a11546ab3a PHPC-1235: Update tests due to changes in MongoDB 4.1 2019-02-14 15:35:30 -05:00
Derick Rethans
a73187c5b5 PHPC-1123: Create interface for Cursor class 2018-10-09 14:16:38 +01:00
Derick Rethans
da511cb46a Split tests into pre and post 3.6 versions due to changes in exception class 2018-09-05 18:36:44 +01:00
Derick Rethans
b45a519c43 Added getMore failpoint skip_if 2018-09-05 18:36:44 +01:00
Derick Rethans
8ece2a3a35 PHPC-1179: Reimplement tests that start servers with Mongo Orchestration 2018-09-05 18:36:44 +01:00
Derick Rethans
3678fa5236 PHPC-1184: Add alternative topologies to Travis 2018-07-16 10:30:39 +01:00
Jeremy Mikola
ef06e624c8 $changeStream requires WiredTiger storage engine 2018-06-25 16:17:10 -04:00
Jeremy Mikola
0f07beb7c5 PHPC-1211: Update SKIPIFs for 32-bit platforms 2018-06-22 13:07:33 -04:00
Jeremy Mikola
dcc2fdf259 PHPC-1113: Use XFAIL instead of skips for tests to be reimplemented 2018-05-03 11:52:45 -04:00
Jeremy Mikola
8ca94d01e6 PHPC-1113: Use >=3.1 for version skips instead of >3.0.99 2018-05-03 11:37:04 -04:00
Jeremy Mikola
27a0452ecf PHPC-1113: Disable tests that start servers with MO (defer to PHPC-1179) 2018-05-02 16:04:09 -04:00
Jeremy Mikola
58fa85e85e PHPC-1113: Use common URI constant 2018-05-02 16:04:09 -04:00
Jeremy Mikola
037e393faa PHPC-1113: Replace NEEDS('STANDALONE_30') with skip functions 2018-05-02 16:04:08 -04:00
Jeremy Mikola
5f7f350670 PHPC-1113: Replace NEEDS('STANDALONE') with skip function 2018-05-02 16:04:08 -04:00
Jeremy Mikola
b4062f880c PHPC-1113: Replace CLEANUP() with skip function 2018-05-02 16:04:08 -04:00
Jeremy Mikola
3a1362bb8d PHPC-1113: Replace NEEDS('REPLICASET') with skip function 2018-05-02 16:04:08 -04:00
Jeremy Mikola
fe52b484be PHPC-1113: Replace NEEDS_ATLEAST_MONGODB_VERSION() with skip function 2018-05-02 16:04:07 -04:00
Jeremy Mikola
8a83606e9b PHPC-1113: Replace NEEDS_CRYPTO() with skip function 2018-05-02 16:04:07 -04:00
Jeremy Mikola
480bc58cd3 Merge branch 'v1.4' 2018-04-18 16:08:00 -04:00
Jeremy Mikola
fdc7565507 PHPC-1161: Free reference to Session once Cursor is exhausted 2018-04-18 14:37:51 -04:00
Jeremy Mikola
427854e092 PHPC-1152: Create implicit session for commands
This ensures that phongo_execute_command creates an implicit session (if supported and not explicit session was provided). In turn, this ensures that any command cursor shares the same session as its originating command.

By creating a Session object, we can ensure that the implicit session is destroyed during garbage collection when the last reference is removed.
2018-04-18 14:36:39 -04:00
Jeremy Mikola
0cb33f6c63 Merge branch 'v1.4' 2018-04-18 12:59:43 -04:00
Jeremy Mikola
1dfc8df053 PHPC-1162: Add reference to currentDocument in debug info
This fixes a segfault while dumping the cursor between iterations with IteratorIterator.
2018-04-18 12:02:55 -04:00