Skip to content

Commit 04c29be

Browse files
Merge v1.20 into v1.x (#1651)
2 parents dfc8a85 + 3a62cd6 commit 04c29be

File tree

48 files changed

+449
-241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+449
-241
lines changed

.evergreen/config/build-variants.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,26 @@ buildvariants:
3636
run_on: rhel90-small
3737
tasks:
3838
- name: "build-all-php"
39-
- name: build-rhel83-zseries
40-
display_name: "Build: RHEL 8.3 Zseries"
39+
- name: build-rhel8-zseries
40+
display_name: "Build: RHEL 8 Zseries"
4141
tags: ["build", "rhel", "zseries", "tag"]
42-
run_on: rhel83-zseries-small
42+
run_on: rhel8-zseries-small
4343
tasks:
4444
- name: "build-all-php"
45-
- name: build-rhel82-arm64
46-
display_name: "Build: RHEL 8.2 ARM64"
45+
- name: build-rhel8-arm64
46+
display_name: "Build: RHEL 8 ARM64"
4747
tags: ["build", "rhel", "arm64", "tag"]
4848
run_on: rhel82-arm64
4949
tasks:
5050
- name: "build-all-php"
51-
- name: build-rhel81-power8
52-
display_name: "Build: RHEL 8.1 Power8"
51+
- name: build-rhel8-power8
52+
display_name: "Build: RHEL 8 Power8"
5353
tags: ["build", "rhel", "power8", "tag"]
54-
run_on: rhel81-power8-large
54+
run_on: rhel8-power-large
5555
tasks:
5656
- name: "build-all-php"
57-
- name: build-rhel80
58-
display_name: "Build: RHEL 8.0"
57+
- name: build-rhel8
58+
display_name: "Build: RHEL 8 x64"
5959
tags: ["build", "rhel", "x64", "pr", "tag"]
6060
run_on: rhel80-small
6161
tasks:

src/BSON/UTCDateTime.c

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,35 @@ static bool php_phongo_utcdatetime_init_from_date(php_phongo_utcdatetime_t* inte
104104
return true;
105105
}
106106

107+
static bool php_phongo_utcdatetime_init_from_object(php_phongo_utcdatetime_t* intern, zend_object* object)
108+
{
109+
if (instanceof_function(object->ce, php_date_get_interface_ce())) {
110+
php_phongo_utcdatetime_init_from_date(intern, php_date_obj_from_obj(object));
111+
112+
return true;
113+
}
114+
115+
if (instanceof_function(object->ce, php_phongo_int64_ce)) {
116+
php_phongo_utcdatetime_init(intern, php_int64_fetch_object(object)->integer);
117+
118+
return true;
119+
}
120+
121+
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected instance of %s or %s, %s given", ZSTR_VAL(php_date_get_interface_ce()->name), ZSTR_VAL(php_phongo_int64_ce->name), ZSTR_VAL(object->ce->name));
122+
123+
return false;
124+
}
125+
126+
static bool php_phongo_utcdatetime_init_from_double(php_phongo_utcdatetime_t* intern, double milliseconds)
127+
{
128+
char tmp[24];
129+
int tmp_len;
130+
131+
tmp_len = snprintf(tmp, sizeof(tmp), "%.0f", milliseconds > 0 ? floor(milliseconds) : ceil(milliseconds));
132+
133+
return php_phongo_utcdatetime_init_from_string(intern, tmp, tmp_len);
134+
}
135+
107136
static HashTable* php_phongo_utcdatetime_get_properties_hash(zend_object* object, bool is_temp)
108137
{
109138
php_phongo_utcdatetime_t* intern;
@@ -179,36 +208,27 @@ static PHP_METHOD(MongoDB_BSON_UTCDateTime, __construct)
179208
return;
180209
}
181210

182-
if (Z_TYPE_P(milliseconds) == IS_OBJECT) {
183-
if (instanceof_function(Z_OBJCE_P(milliseconds), php_date_get_interface_ce())) {
184-
php_phongo_utcdatetime_init_from_date(intern, Z_PHPDATE_P(milliseconds));
185-
} else {
186-
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected instance of DateTimeInterface, %s given", ZSTR_VAL(Z_OBJCE_P(milliseconds)->name));
187-
}
188-
return;
189-
}
190-
191-
if (Z_TYPE_P(milliseconds) == IS_LONG) {
192-
php_phongo_utcdatetime_init(intern, Z_LVAL_P(milliseconds));
193-
return;
194-
}
211+
switch (Z_TYPE_P(milliseconds)) {
212+
case IS_OBJECT:
213+
php_phongo_utcdatetime_init_from_object(intern, Z_OBJ_P(milliseconds));
214+
return;
195215

196-
if (Z_TYPE_P(milliseconds) == IS_DOUBLE) {
197-
char tmp[24];
198-
int tmp_len;
216+
case IS_LONG:
217+
php_phongo_utcdatetime_init(intern, Z_LVAL_P(milliseconds));
218+
return;
199219

200-
tmp_len = snprintf(tmp, sizeof(tmp), "%.0f", Z_DVAL_P(milliseconds) > 0 ? floor(Z_DVAL_P(milliseconds)) : ceil(Z_DVAL_P(milliseconds)));
220+
case IS_DOUBLE:
221+
php_phongo_utcdatetime_init_from_double(intern, Z_DVAL_P(milliseconds));
222+
return;
201223

202-
php_phongo_utcdatetime_init_from_string(intern, tmp, tmp_len);
203-
return;
204-
}
224+
case IS_STRING:
225+
php_error_docref(NULL, E_DEPRECATED, "Creating a %s instance with a string is deprecated and will be removed in ext-mongodb 2.0", ZSTR_VAL(php_phongo_utcdatetime_ce->name));
205226

206-
if (Z_TYPE_P(milliseconds) != IS_STRING) {
207-
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected integer or string, %s given", PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(milliseconds));
208-
return;
227+
php_phongo_utcdatetime_init_from_string(intern, Z_STRVAL_P(milliseconds), Z_STRLEN_P(milliseconds));
228+
return;
209229
}
210230

211-
php_phongo_utcdatetime_init_from_string(intern, Z_STRVAL_P(milliseconds), Z_STRLEN_P(milliseconds));
231+
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected integer or string, %s given", PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(milliseconds));
212232
}
213233

214234
static PHP_METHOD(MongoDB_BSON_UTCDateTime, __set_state)

src/BSON/UTCDateTime.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
final class UTCDateTime implements UTCDateTimeInterface, \JsonSerializable, Type, \Serializable, \Stringable
1111
{
12-
final public function __construct(int|string|float|\DateTimeInterface|null $milliseconds = null) {}
12+
final public function __construct(int|string|float|\DateTimeInterface|Int64|null $milliseconds = null) {}
1313

1414
final public function toDateTime(): \DateTime {}
1515

src/BSON/UTCDateTime_arginfo.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/MongoDB/Monitoring/CommandFailedEvent.c

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ zend_class_entry* php_phongo_commandfailedevent_ce;
3131

3232
PHONGO_DISABLED_CONSTRUCTOR(MongoDB_Driver_Monitoring_CommandFailedEvent)
3333

34-
/* Returns the command name for this event */
3534
static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getCommandName)
3635
{
3736
php_phongo_commandfailedevent_t* intern;
@@ -43,7 +42,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getCommandName)
4342
RETVAL_STRING(intern->command_name);
4443
}
4544

46-
/* Returns the database name for this event */
4745
static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getDatabaseName)
4846
{
4947
php_phongo_commandfailedevent_t* intern;
@@ -55,7 +53,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getDatabaseName)
5553
RETVAL_STRING(intern->database_name);
5654
}
5755

58-
/* Returns the event's duration in microseconds */
5956
static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getDurationMicros)
6057
{
6158
php_phongo_commandfailedevent_t* intern;
@@ -67,7 +64,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getDurationMicro
6764
RETURN_LONG(intern->duration_micros);
6865
}
6966

70-
/* Returns the error document associated with the event */
7167
static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getError)
7268
{
7369
php_phongo_commandfailedevent_t* intern;
@@ -79,7 +75,15 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getError)
7975
RETURN_ZVAL(&intern->z_error, 1, 0);
8076
}
8177

82-
/* Returns the event's operation ID */
78+
static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getHost)
79+
{
80+
php_phongo_commandfailedevent_t* intern = Z_COMMANDFAILEDEVENT_OBJ_P(getThis());
81+
82+
PHONGO_PARSE_PARAMETERS_NONE();
83+
84+
RETVAL_STRING(intern->host.host);
85+
}
86+
8387
static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getOperationId)
8488
{
8589
php_phongo_commandfailedevent_t* intern;
@@ -93,7 +97,15 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getOperationId)
9397
RETVAL_STRING(operation_id);
9498
}
9599

96-
/* Returns the reply document associated with the event */
100+
static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getPort)
101+
{
102+
php_phongo_commandfailedevent_t* intern = Z_COMMANDFAILEDEVENT_OBJ_P(getThis());
103+
104+
PHONGO_PARSE_PARAMETERS_NONE();
105+
106+
RETVAL_LONG(intern->host.port);
107+
}
108+
97109
static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getReply)
98110
{
99111
php_phongo_commandfailedevent_t* intern;
@@ -113,7 +125,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getReply)
113125
RETURN_ZVAL(&state.zchild, 0, 1);
114126
}
115127

116-
/* Returns the event's request ID */
117128
static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getRequestId)
118129
{
119130
php_phongo_commandfailedevent_t* intern;
@@ -127,7 +138,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getRequestId)
127138
RETVAL_STRING(request_id);
128139
}
129140

130-
/* Returns the Server from which the event originated */
131141
static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getServer)
132142
{
133143
php_phongo_commandfailedevent_t* intern;
@@ -139,7 +149,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getServer)
139149
phongo_server_init(return_value, &intern->manager, intern->server_id);
140150
}
141151

142-
/* Returns the event's service ID */
143152
static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getServiceId)
144153
{
145154
php_phongo_commandfailedevent_t* intern = Z_COMMANDFAILEDEVENT_OBJ_P(getThis());
@@ -153,7 +162,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getServiceId)
153162
phongo_objectid_new(return_value, &intern->service_id);
154163
}
155164

156-
/* Returns the event's server connection ID */
157165
static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getServerConnectionId)
158166
{
159167
php_phongo_commandfailedevent_t* intern = Z_COMMANDFAILEDEVENT_OBJ_P(getThis());
@@ -174,12 +182,6 @@ static PHP_METHOD(MongoDB_Driver_Monitoring_CommandFailedEvent, getServerConnect
174182
RETURN_LONG(intern->server_connection_id);
175183
}
176184

177-
/**
178-
* Event thrown when a command has failed to execute.
179-
*
180-
* This class is only constructed internally.
181-
*/
182-
183185
/* MongoDB\Driver\Monitoring\CommandFailedEvent object handlers */
184186
static zend_object_handlers php_phongo_handler_commandfailedevent;
185187

@@ -233,24 +235,26 @@ static HashTable* php_phongo_commandfailedevent_get_debug_info(zend_object* obje
233235

234236
intern = Z_OBJ_COMMANDFAILEDEVENT(object);
235237
*is_temp = 1;
236-
array_init_size(&retval, 6);
238+
array_init_size(&retval, 11);
237239

240+
ADD_ASSOC_STRING(&retval, "host", intern->host.host);
241+
ADD_ASSOC_LONG_EX(&retval, "port", intern->host.port);
238242
ADD_ASSOC_STRING(&retval, "commandName", intern->command_name);
239243
ADD_ASSOC_INT64(&retval, "durationMicros", intern->duration_micros);
240244

241245
ADD_ASSOC_ZVAL_EX(&retval, "error", &intern->z_error);
242246
Z_ADDREF(intern->z_error);
243247

244-
snprintf(operation_id, sizeof(operation_id), "%" PRId64, intern->operation_id);
245-
ADD_ASSOC_STRING(&retval, "operationId", operation_id);
246-
247248
if (!php_phongo_bson_to_zval_ex(intern->reply, &reply_state)) {
248249
zval_ptr_dtor(&reply_state.zchild);
249250
goto done;
250251
}
251252

252253
ADD_ASSOC_ZVAL(&retval, "reply", &reply_state.zchild);
253254

255+
snprintf(operation_id, sizeof(operation_id), "%" PRId64, intern->operation_id);
256+
ADD_ASSOC_STRING(&retval, "operationId", operation_id);
257+
254258
snprintf(request_id, sizeof(request_id), "%" PRId64, intern->request_id);
255259
ADD_ASSOC_STRING(&retval, "requestId", request_id);
256260

src/MongoDB/Monitoring/CommandFailedEvent.stub.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,17 @@ final public function getDurationMicros(): int {}
2020

2121
final public function getError(): \Exception {}
2222

23+
final public function getHost(): string {}
24+
2325
final public function getOperationId(): string {}
2426

27+
final public function getPort(): int {}
28+
2529
final public function getReply(): object {}
2630

2731
final public function getRequestId(): string {}
2832

33+
/** @deprecated */
2934
final public function getServer(): \MongoDB\Driver\Server {}
3035

3136
final public function getServiceId(): ?\MongoDB\BSON\ObjectId {}

src/MongoDB/Monitoring/CommandFailedEvent_arginfo.h

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)