* 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
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.
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.
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>
* 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
* 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
* BSON corpus prose tests for null bytes
For tests that already existed we just add a reference to the prose test
* BSON corpus tests for null bytes
Synced with mongodb/specifications@c64fc79899
This sync also removes some old DBRef tests, which should have been removed in 6929bcb608.
* Bump libmongoc to 1.19.1 to pull in changes from CDRIVER-4083
* 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
* 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
* PHPC-1839 Fix accessing referenced non-interned strings
* Use ZVAL_DEREF
* Update tests to not require a live server
* Use correct case for method names
* PHPC-1813: Unpin session after aborting a transaction
Bumps libmongoc dependency to pull in changes from CDRIVER-3949
* Revise Extended JSON tests for CDRIVER-3958
* 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
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.