Commit Graph

70 Commits

Author SHA1 Message Date
Andreas Braun
6ffcb1f1dd PHPC-2117: Test on PHP 8.2 (#1340)
* Test on PHP 8.2

* Fix tests relating to dynamic properties

* Fix tests failing due to different __set_state output

* Duplicate clone test without dynamic properties for PHP >= 8.2
2022-08-04 08:53:25 +02: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
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
Jeremy Mikola
bd10948415 PHPC-1849: Handle deprecation of Serializable in PHP 8.1 (#1246)
* Add __serialize and __unserialize methods to Serializable classes

These methods will be used on PHP 7.4+ when available. Implementing them is required to suppress a deprecation notice on PHP 8.1+.

This commit also renames is_debug parameter for get_properties_hash utility functions (and related macros) to more accurately reflect its purpose of allocating a new HashTable instead of using an internal props table.

* Explicitly handle serialize output in php_phongo_cursorid_get_properties_hash

* Explicitly handle serialize output in php_phongo_writeconcern_get_properties_hash

* Note maxStalenessSeconds handling in php_phongo_readpreference_get_properties_hash

* CursorId should always serialize id as string
2021-08-31 22:13:11 -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
d70efb6ea6 PHPC-1700: Fix memory leak when read preference is invalid (#1179)
* PHPC-1700: Fix memory leak in prep_tagsets

* PHPC-1701: Add regression test for memory leak in prep_authmechanisms
2020-11-25 10:39:38 +01:00
Jeremy Mikola
9fc51c842b PHPC-1698: fix prep_tagsets leak for ReadPreference::__set_state (#1167) 2020-10-12 12:52:19 +02:00
Andreas Braun
a449493052 Fix error message for maxStaleness with primary read preference 2020-05-27 12:35:04 +02:00
Andreas Braun
5027842983 PHPC-1571: Support server hedged reads via read preference 2020-05-27 12:35:04 +02:00
Jeremy Mikola
354bcc9441 PHPC-1598: Fix get_gc handlers for classes with get_properties
The ReadConcern, ReadPreference, WriteConcern, and BSON classes have no properties beyond pointers to libmongoc/libbson structs; however, all of these classes use get_properties to report fields for var_export (PHPC-850, PHPC-460).

The standard get_gc handler defers to get_properties to collect other zvals for GC inspection. This is problematic for the aforementioned get_properties handlers, since a HashTable of zvals intended for debugging will be returned and those properties will already be freed by our free_object handler (via FREE_HASHTABLE).

Having each class define its own get_gc handler is the first step to fixing this issue. The BSON classes already defined their own get_gc handlers, but erroneously returned the internally cached properties directly.

The second step to fixing this issue is ensuring that get_gc delegates to zend_std_get_properties, as is done in various PHP core extensions. Doing so ensures that we do not leak other zvals that may be assigned as public properties by the application (covered by the second regression test), since zend_std_get_properties will return those for GC inspection.
2020-05-19 18:14:53 -04:00
Andreas Braun
24de9ca68c PHPC-1491: Expose string read preference constants 2019-12-05 22:05:05 +01:00
Andreas Braun
e3a84d7542 PHPC-1491: Expose read preference mode as string 2019-12-05 22:05:05 +01:00
Andreas Braun
c7a8bf1a14 PHPC-1281: Add Serializable support for MongoDB\Driver\ReadPreference 2019-10-18 13:45:13 -04:00
Jeremy Mikola
c81c593ef3 PHPC-1331: Use literal value in ReadPreference::__set_state() error test
This value is closer to the valid upper bound and consistent with the ctor error test for maxStalenessSeconds.
2019-02-19 20:23:20 -05:00
Jeremy Mikola
4a116c5a2b PHPC-1331: Fix typos in ReadPreference exception messages 2019-02-19 20:23:20 -05:00
Derick Rethans
9cbb01a860 PHPC-1206: Add __set_state() support for ReadPreference 2018-10-19 16:26:17 -04:00
Derick Rethans
d07d180dd6 Merge branch 'v1.5' 2018-09-20 18:14:16 +01:00
Derick Rethans
3624e5acfd PHPC-1272: phongo_execute_query() should not alter state of Query opts 2018-09-20 17:37:09 +01:00
Derick Rethans
0ec480fd65 Merge branch 'v1.5' 2018-08-30 11:49:22 +01:00
Derick Rethans
9778b84da7 PHPC-1263: Fix tests for PHP 7.3 output changes 2018-08-30 11:49:01 +01:00
Derick Rethans
c80778a153 PHPC-1173: Reimplement replica set seedlist tests 2018-08-10 11:26:42 +01:00
Derick Rethans
f12e2005b4 PHPC-850: var_export() support for ReadPreference 2018-06-07 17:08:22 +01: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
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
cc90304658 PHPC-1151: Add Session to Cursor debug output 2018-04-16 11:28:21 -04:00
Jeremy Mikola
b29c423fda PHPC-1057: Refactor option parsing for execute methods
Execute options are now parsed via php_array functions, which makes the options case-sensitive.

A helper function is now used to convert legacy options for the original three execute methods into an array. This simplifies option parsing in php_phongo.c.

Additionally, Manager methods now perform their own server selection, which means that execute functions in php_phongo.c can rely on a server_id being provided.

Tests have been updated to expect a serverId option when relevant (e.g. query opts). Additionally, error tests for execute methods have been improved so that invalid values for all known options are tested.
2017-12-18 12:11:57 -05:00
Jeremy Mikola
ecaeb2c1a2 Replace tabs with spaces in test files 2017-12-12 08:17:59 -05:00
Derick Rethans
68bb32c6f7 PHPC-904: ReadPreference constructor should accept strings 2017-04-04 16:55:49 +01:00
Jeremy Mikola
21172ea914 mongoc_cursor_is_alive() now returns false when cursors have no results 2017-03-28 18:35:35 -04:00
Jeremy Mikola
e6b8479506 Reorganize SKIPIF blocks in tests and add missing NEEDS() checks 2017-03-15 10:41:04 -04:00
Jeremy Mikola
120b270377 PHPC-851: Separate argument zvals before modification
This primarily fixes a bug introduced in 6d46d62577 for PHPC-359, since we convert tag sets from arrays to objects to ensure proper BSON serialization. Not only was the array mutation visible to calling contexts, but a crash could occur if the array was immutable due to OPcache.

For Manager's $driverOptions, a comment in 1060cb8ba4 for PHPC-433 indicated that we should have separated its zval due to possible modification, but the appropriate zend_parse_parameters() flag was never used.
2016-12-12 19:31:45 -05:00
Derick Rethans
43b06f0ca3 PHPC-827: Update Max Staleness implementation 2016-11-28 11:32:01 +00:00
Jeremy Mikola
a267e05eb8 Comprehensive tests for RC, RP, and WC debug output and BSON serialization 2016-09-26 10:53:21 -04:00
Jeremy Mikola
6d46d62577 PHPC-359: Ensure RP tag sets serialize as documents 2016-09-26 10:53:21 -04:00
Jeremy Mikola
f37f589bbc PHPC-783: Use mongoc_collection_find_with_opts() for Query exec
Query struct fields have been consolidated to a filter and opts BSON documents.

This also changes the Query debug output significantly.
2016-09-20 16:57:20 -04:00
Jeremy Mikola
77209dd65d PHPC-752: Add maxStalenessMS to ReadPreference class
This adds an options array to the ReadPreference constructor, which accepts a maxStalenessMS option. The option is also exposed via a getter method and in debug output.
2016-09-19 16:54:48 -04:00
Jeremy Mikola
40a0f52cc0 Use short array syntax in ReadPreference tests 2016-09-19 16:54:48 -04:00
Jeremy Mikola
d9b6613562 Remove unnecessary SKIPIFs from ReadPreference tests 2016-09-19 16:54:48 -04:00
Jeremy Mikola
11d823f8cd PHPC-498: Fix expected output for ReadPreference and WriteConcern
These test fixes were missed in mongodb/mongo-php-driver#413.
2016-09-19 16:52:38 -04:00
Derick Rethans
8f9e6c8c53 PHPC-498: ReadPreference, ReadConcern, and WriteConcern should serialize to BSON 2016-09-19 20:33:14 +01:00
Jeremy Mikola
5568225fcd Fix test name for ReadPreference::getTagSets() 2016-09-15 12:41:17 -04:00
Jeremy Mikola
56d8b77b15 PHPC-424: Validate that RP tag set is an array of documents
This adds common validation for read preference tag sets when specified through either the Manager constructor's URI options array or ReadPreference constructor.

An additional test case for a malformed tag set has been added to the Manager::__construct() error test for read preference options. Additionally, the ReadPreference::__construct() error test has been split up to test for mode and tagSet errors separately.

Note: we cannot test for the exceptions for bson_init_static() and mongoc_read_prefs_is_valid(), since those points will never be hit in normal operation.
2016-09-15 12:40:27 -04:00
Jeremy Mikola
c0046a3e63 PHPC-673: Fix Cursor::isDead() tests for mongoc_cursor_is_alive()
This changes our tests based on upstream fixes for mongoc_cursor_is_alive() in CDRIVER-1221.
2016-05-17 16:12:13 -04:00
Jeremy Mikola
78839bde83 PHPC-688: Change Cursor debug handler to use libmongoc public API
This significantly alters the structure of the Cursor's debug output, since we not longer have access to private fields within mongoc_cursor_t.
2016-05-06 11:48:31 -04:00
Jeremy Mikola
2fa57d7d05 Regression test for extending final classes 2016-02-09 15:25:14 -05:00
Jeremy Mikola
b54a8bf05b PHPC-450: Split query tests for OP_QUERY and find command
This also entails a change to done/end_of_event cursor field assertions. These are internal libmongoc cursor fields and their values aren't relevant to the tests. In the future, we may consider removing them from the Cursor's dump output.
2015-12-10 12:16:36 -05:00
Hannes Magnusson
49225e1dc7 PHPC-495: Upgrade bundled libbson and libmongoc to 1.3.0 2015-12-02 18:11:46 +00:00