399 Commits

Author SHA1 Message Date
Jeremy Mikola
49e09578b7 Valid read preference tag sets should always be documents
This function was originally implemented in PHPC-424, before we started preparing tag sets in PHPC-359 to ensure that they serialized as BSON documents. There is no longer any reason to allow array types here.
2016-12-12 19:31:46 -05: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
Jeremy Mikola
32b93dba33 Move cursor iterator handlers into Cursor.c 2016-12-12 12:59:00 -05:00
Jeremy Mikola
0bf726420b Use zend_hash ptr functions for PHP7 2016-12-12 12:57:41 -05:00
Jeremy Mikola
3daf370d4b PHPC-854: Initialize persistent client hash directly in GINIT
Previous initialization during MINIT and using the accessor macro was causing crashes in Apache.

This also declares externs for TSRMLS_CACHE, as is done in other extensions.
2016-12-12 12:57:41 -05:00
Derick Rethans
c50d63d74f PHPC-533: Remove PHONGO_API macro for exported functions 2016-11-28 11:47:13 +00:00
Derick Rethans
43b06f0ca3 PHPC-827: Update Max Staleness implementation 2016-11-28 11:32:01 +00:00
Jeremy Mikola
6dc41c409f PHPC-676: Do not allow BulkWrite objects to be executed multiple times 2016-11-22 11:10:02 -05:00
Jeremy Mikola
342b7de4a9 PHPC-718: Define extension dependencies 2016-11-08 13:28:42 -05: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
0160871af6 PHPC-752: Validate range of maxStalenessMS Manager option
This also adds various tests for parsing of read preference Manager options.
2016-09-19 16:54:48 -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
467b981f95 Move (char *) casting to ADD_ASSOC_STRING macro
This is necessary since PHP's add_assoc_string_ex() declares the argument as char *, even though it never modifies the string contents and later assigns it to a const char * internally. Since we always duplicate the string for PHP 5.x and it is never modified in PHP 7, there is no harm in this cast.
2016-09-19 16:13:05 -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
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
Derick Rethans
2cbbd69404 PHPC-786: Support appname in URI array options 2016-09-14 18:21:13 +01:00
Jeremy Mikola
8fbf0fa4db PHPC-605: Remove unused php-ssl.c contrib code 2016-09-14 10:29:36 -04:00
Jeremy Mikola
9717d5cac6 PHPC-605: crl_file is not supported by LibreSSL or Secure Transport 2016-09-08 11:10:35 -04:00
Jeremy Mikola
a5667e6c9a PHPC-605: Split exceptions for unsupported ca_dir and capath options 2016-09-08 11:10:34 -04:00
Jeremy Mikola
3036797f41 Use consistent memory allocation for write error messages
These strings were released with efree() in the object destructors and should be allocated with emalloc().
2016-09-08 11:10:34 -04:00
Jeremy Mikola
29e5121cb7 PHPC-433: Persist mongoc_client_t objects in a HashTable
Clients will be hashed by Manager constructor arguments. Since they must persist between requests, the Manager destructor will no longer free the client and we'll need to start using persistent memory allocation for libbson and libmongoc.
2016-09-08 11:10:34 -04:00
Jeremy Mikola
1060cb8ba4 PHPC-433: Refactor phongo_manager_init() option handling
BSON conversion of uriOptions moves to phongo_manager_init(). Merging of stream context options into driverOptions and removal of the context resource is now done in the Manager constructor.

phongo_manager_init() now has zvals for both uriOptions and driverOptions and will be able to serialize them with the URI string for a client hash.
2016-09-07 18:08:19 -04:00
Jeremy Mikola
e5db9dd2ff PHPC-605: Fix exception logic for unsupported ca_dir option 2016-09-07 18:08:19 -04:00
Jeremy Mikola
c673e0aee2 PHPC-704: Do not set mongodb.debug from driver options
The mongodb.debug INI option is a global setting and should not be set based on a single Manager's constructor argument.
2016-09-07 18:08:19 -04:00
Derick Rethans
0ab5d5c74c PHPC-752: Allow users to set a limit on acceptable staleness 2016-08-31 14:41:58 -04:00
Derick Rethans
91aaf65b9d PHPC-757: Implement The MongoDB Handshake Protocol 2016-08-31 19:20:44 +01:00
Derick Rethans
24b65ca159 PHPC-619: Implement Decimal128 type (again) 2016-08-31 17:13:17 +01:00
Derick Rethans
7f761be64f Upgrade libbson and libmongoc to latest master (1.5.0-dev) 2016-08-31 12:28:02 +01:00
Jeremy Mikola
f7e2b09165 PHPC-605: Rely on libmongoc for socket IO and TLS 2016-08-30 14:04:56 -04:00
Jeremy Mikola
a6e7202498 PHPC-761: Remove BSON_NAMESPACE constant 2016-08-05 14:06:58 -04:00
ian boros
e545a5d52b PHPC-755: Remove include of private mongoc-trace.h 2016-07-29 18:13:58 -04:00
Jeremy Mikola
ff79f64177 PHPC-758: Disable Decimal128 for bundled libbson and libmongoc 1.4.0 2016-07-29 18:11:41 -04:00
Jeremy Mikola
5c65399eca Define ZSTR_VAL() for PHP 5 and remove phongo_str() macro 2016-07-14 11:27:18 -04:00
Jeremy Mikola
b3298a0efe PHPC-739: Rename "javascript" to "code" in Javascript BSON class
This changes behavior of var_dump(), var_export(), and serialization.

Additionally, this renames the internal struct fields to be consistent with the publicized property names.
2016-07-13 10:32:45 -04:00
Jeremy Mikola
10e1879357 PHPC-460: UTCDateTime serialization and var_export 2016-07-12 16:30:43 -04:00
Jeremy Mikola
0a32ce98fb PHPC-460: Timestamp serialization and var_export 2016-07-12 16:30:43 -04:00
Jeremy Mikola
4be966906a PHPC-460: Decimal128 serialization and var_export 2016-07-12 16:30:42 -04:00
Jeremy Mikola
9b290494a2 PHPC-460: ObjectID serialization and var_export 2016-07-12 16:30:42 -04:00
Jeremy Mikola
f59e0f83dc Merge branch 'v1.1' 2016-07-05 14:21:00 -04:00
Jeremy Mikola
99e499ab55 Trace returns from phongo_stream_initiator() 2016-07-05 13:51:31 -04:00
Jeremy Mikola
b67907e7f6 PHPC-720: Do not persist SSL streams to avoid SSL reinitialization errors 2016-07-05 13:51:30 -04:00
Jeremy Mikola
658fd8f51c Merge branch 'v1.1' 2016-06-27 12:08:28 -04:00
Jeremy Mikola
0d0b14b9cd Move php_phongo_new_datetime_from_utcdatetime() into UTCDateTime.c
This function was only used by UTCDateTime::toDateTime(), so it does not need to be in php_phongo.c. Additionally, this commit removes the platform-specific spprintf patterns in favor of the portable PRId64 pattern.
2016-06-27 11:53:41 -04:00
Jeremy Mikola
ceb506d636 Merge branch 'v1.1' 2016-06-27 11:04:44 -04:00
Yuriy
08902baa09 PHPC-631: Fix timelib_time.f assignment in UTCDateTime::toDateTime() 2016-06-21 16:37:05 -04:00
Jeremy Mikola
5ce569719c PHPC-619: Implement Decimal BSON type 2016-06-21 08:35:21 -04:00
Jeremy Mikola
a327a22cb8 Merge branch 'v1.1' 2016-06-02 11:20:03 -04:00
Jeremy Mikola
857ab5199b Use php_stream_context_from_zval() to get default stream context
This initializes the default context if it is not already set.
2016-06-01 22:56:21 -04:00
Jeremy Mikola
3b06e81f9a PHPC-572: Keep stream context options alive for Manager's lifetime 2016-06-01 22:54:08 -04:00