Commit Graph

299 Commits

Author SHA1 Message Date
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
b73afcd482 PHPC-2053: Remove mongodb.mock_service_id INI option
Note: this was only used for internal testing and should not be considered a BC break.
2022-05-23 13:55:40 -04:00
Jeremy Mikola
0960a204b3 PHPC-2037: Remove vim modeline comments 2022-01-26 20:31:48 -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
17b4a343fa Remove obsolete function declaration
This function was removed in 324182a8e6
2022-01-26 20:31:48 -05:00
Jeremy Mikola
5d97f64080 PHPC-1805: Remove redundant function declaration
This was introduced in 10b3a1fe70, but was redundant due to the subsequent macro definition.
2022-01-24 13:34:10 -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
594e83bad4 PHPC-1976: Add serviceId to command monitoring events 2021-10-15 13:44:32 -04:00
Jeremy Mikola
2fb1836358 PHPC-1979: Use mongoc_client_get_handshake_description for load balancers
This ensures that Server::getInfo() returns a usable hello response (e.g. for wire version checks). The debug info is also addressed for consistency.
2021-10-15 13:44:31 -04:00
Jeremy Mikola
797a5c81f7 PHPC-1980: Server::TYPE_LOAD_BALANCER constant 2021-10-15 13:44:31 -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
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
Remi Collet
5d7796b19b PHPC-1922 Update PHONGO_CE_DISABLE_SERIALIZATION for PHP 8.1 (#1240)
* Fix API change in 8.1.0beta1

* cleanup uneeded semicolon

* Fix clang-format complaints

Co-authored-by: Andreas Braun <git@alcaeus.org>
2021-07-27 11:40:22 +02:00
Tanli Su
fb150df0c4 PHPC-1513: Remove php_phongo_cursor_to_zval (#1227) 2021-06-22 10:06:41 -04:00
Alexander Golin
68019a258a PHPC-1792: Change all copyrights to be <year>-present (#1217) 2021-05-03 09:04:08 -04:00
Andreas Braun
a6e9c507cd Fix clang-format violation 2021-03-01 12:41:05 +01:00
Jeremy Mikola
19cf10110c PHPC-1366: Declare libbson vtable in MINIT instead of using a global 2021-01-20 00:54:57 -05: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
707da29722 PHPC-1442: Remove empty TSRMLS macros 2020-02-11 14:06:10 +01:00
Andreas Braun
b7e4a8e718 PHPC-1442: Remove obsolete macros from phongo_compat.h 2020-02-11 14:06:10 +01:00
Andreas Braun
394c325081 PHPC-1442: Drop conditionals for PHP 5 support 2020-02-11 14:06:10 +01:00
Andreas Braun
f0372a50c5 PHPC-1499: Implement ClientEncryption::decrypt 2020-01-22 08:18:32 +01:00
Andreas Braun
4d7b35ee69 PHPC-1499: Implement ClientEncryption::encrypt 2020-01-22 08:18:32 +01:00
Andreas Braun
e65a933c8f PHPC-1499: Implement ClientEncryption::createDataKey 2020-01-22 08:18:32 +01:00
Andreas Braun
4923bdd97b PHPC-1499: Add empty ClientEncryption class 2020-01-22 08:18:32 +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
Jeremy Mikola
366dcbe7d2 PHPC-1411: Prefer integer types for wtimeout when possible
For serialization, 64-bit wtimeout values will always be encoded as strings for portability. Debug output and bsonSerialize() can always use integers on 64-bit platforms and can fall back to strings and Int64 objects on 32-bit platforms, respectively.
2019-12-19 06:51:06 +01:00
Andreas Braun
cdff70faf6 PHPC-1411: Accept 64-bit integers for wTimeoutMS 2019-12-19 06:50:41 +01:00
Andreas Braun
67d8db55f6 PHPC-1471: Clean up reference handling in Javascript scope serialisation 2019-11-28 10:17:04 +01:00
Andreas Braun
0cee16306c PHPC-1472: Return status of php_phongo_server_to_zval 2019-11-07 07:16:49 +01:00
Andreas Braun
bacb0feb55 PHPC-952: Move BSON type initiators to bson.c 2019-10-21 09:52:46 +02:00
Andreas Braun
d03f36227e PHPC-1290: Adapt server selection logic to respect session pinning 2019-08-28 20:10:46 +02:00
Jeremy Mikola
845edf6867 Merge branch 'v1.5' 2019-05-31 10:09:16 -04:00
Jeremy Mikola
04b1cc3e14 PHPC-1387: Consider error document for cursor exceptions
This allows executeQuery() to throw a CommandException, which exposes the error document.

In 1.6+, it will also ensure that error labels are set on any RuntimeException thrown during cursor iteration, which is relevant for transactions.
2019-05-30 13:58:29 -04:00
Jeremy Mikola
092d82dd95 Relocate "_t" in function name 2019-05-30 12:30:04 -04:00
Jeremy Mikola
cad8292e35 PHPC-1373: Accessible WriteResult for executeBulkWrite socket error
executeBulkWrite() will now throw a BulkWriteException on top of any previous exception to ensure that a WriteResult can be attached. InvalidArgumentException is excluded, since that is only thrown before mongoc_bulk_operation_execute does IO (e.g. batch is empty).
2019-05-15 14:27:16 -04:00
Derick Rethans
26d276407e PHPC-1270: Upgrade libmongoc to 1.13.0 2018-09-20 10:49:49 +01:00
Jeremy Mikola
9f118a2229 PHPC-1211: Int64 class to wrap 64-bit integers on 32-bit platforms 2018-06-22 13:07:33 -04:00
Derick Rethans
b172a20c31 PHPC-1140: Implement Transactions specification 2018-06-19 14:47:29 +01:00
Derick Rethans
f12e2005b4 PHPC-850: var_export() support for ReadPreference 2018-06-07 17:08:22 +01:00
Jeremy Mikola
480bc58cd3 Merge branch 'v1.4' 2018-04-18 16:08:00 -04:00
Jeremy Mikola
aec79b2f12 Refactor command and query execute functions
This corrects the function signatures to return a boolean indicating success instead of an integer (which was cast from a boolean).

Additionally, it restructures phongo_execute_command() to use a cleanup label, in anticipation of implicit session changes.
2018-04-18 13:37:58 -04:00
Jeremy Mikola
230d8d9ab2 Define constant for ExceededTimeLimit server error 2018-04-16 17:03:29 -04:00
Katherine Walker
3125be38ca PHPC-1148: Remove PHONGO_ERROR_WRITE_FAILED 2018-04-12 10:20:58 -04:00
Jeremy Mikola
cf0982b997 Back to -dev 2018-03-06 15:51:24 -05:00
Jeremy Mikola
7e7b4dd30f Package 1.4.2 2018-03-06 15:51:00 -05:00
Derick Rethans
a7576aaa68 PHPC-1114: Add template.rc file to embed the right MongoDB version in the Windows binary 2018-02-27 13:09:40 +00:00
Jeremy Mikola
d52e09ad11 Back to -dev 2018-02-20 14:36:25 -05:00
Jeremy Mikola
138897e595 Package 1.4.1 2018-02-20 14:35:55 -05:00
Derick Rethans
0a5fd12e20 PHPC-1118: Implement use of clang-format 2018-02-20 17:06:55 +00:00