Skip to content

Commit 5ffd929

Browse files
committed
Merge branch 'v1.17'
2 parents 3f221c0 + c45092b commit 5ffd929

File tree

11 files changed

+143
-55
lines changed

11 files changed

+143
-55
lines changed

.evergreen/config/functions.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ functions:
103103
content_type: ${content_type|application/x-gzip}
104104
permissions: public-read
105105
local_file: ${build_id}.tar.gz
106-
remote_file: ${project}/${build_variant}/${revision}/${task_name}/${version}.tar.gz
106+
remote_file: mongo-php-driver/${build_variant}/${revision}/${task_name}/${version_id}.tar.gz
107107

108108
"fetch build":
109109
- command: subprocess.exec
@@ -118,7 +118,7 @@ functions:
118118
aws_key: ${aws_key}
119119
aws_secret: ${aws_secret}
120120
bucket: mciuploads
121-
remote_file: ${project}/${FETCH_BUILD_VARIANT}/${revision}/${FETCH_BUILD_TASK}/${version}.tar.gz
121+
remote_file: mongo-php-driver/${FETCH_BUILD_VARIANT}/${revision}/${FETCH_BUILD_TASK}/${version_id}.tar.gz
122122
local_file: build.tar.gz
123123
- command: archive.targz_extract
124124
params:

.github/workflows/windows/prepare-build/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ runs:
1919
steps:
2020
- name: Setup PHP SDK
2121
id: setup-php
22-
uses: alcaeus/setup-php-sdk@php-8.3
22+
uses: php/setup-php-sdk@v0.8
2323
with:
2424
version: ${{ inputs.version }}
2525
arch: ${{ inputs.arch }}

src/BSON/Document.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <php.h>
1818
#include <ext/standard/base64.h>
19+
#include <Zend/zend_exceptions.h>
1920
#include <Zend/zend_interfaces.h>
2021
#include <Zend/zend_operators.h>
2122
#include <ext/standard/php_var.h>
@@ -167,7 +168,7 @@ static PHP_METHOD(MongoDB_BSON_Document, fromPHP)
167168
RETURN_ZVAL(&zv, 1, 1);
168169
}
169170

170-
static bool php_phongo_document_get(php_phongo_document_t* intern, char* key, size_t key_len, zval* return_value)
171+
static bool php_phongo_document_get(php_phongo_document_t* intern, char* key, size_t key_len, zval* return_value, bool null_if_missing)
171172
{
172173
bson_iter_t iter;
173174

@@ -177,6 +178,11 @@ static bool php_phongo_document_get(php_phongo_document_t* intern, char* key, si
177178
}
178179

179180
if (!bson_iter_find_w_len(&iter, key, key_len)) {
181+
if (null_if_missing) {
182+
ZVAL_NULL(return_value);
183+
return true;
184+
}
185+
180186
phongo_throw_exception(PHONGO_ERROR_RUNTIME, "Could not find key \"%s\" in BSON document", key);
181187
return false;
182188
}
@@ -198,7 +204,7 @@ static PHP_METHOD(MongoDB_BSON_Document, get)
198204

199205
intern = Z_DOCUMENT_OBJ_P(getThis());
200206

201-
if (!php_phongo_document_get(intern, key, key_len, return_value)) {
207+
if (!php_phongo_document_get(intern, key, key_len, return_value, false)) {
202208
// Exception already thrown
203209
RETURN_NULL();
204210
}
@@ -327,7 +333,7 @@ static PHP_METHOD(MongoDB_BSON_Document, offsetGet)
327333
}
328334

329335
// May throw, in which case we do nothing
330-
php_phongo_document_get(intern, Z_STRVAL_P(offset), Z_STRLEN_P(offset), return_value);
336+
php_phongo_document_get(intern, Z_STRVAL_P(offset), Z_STRLEN_P(offset), return_value, false);
331337
}
332338

333339
static PHP_METHOD(MongoDB_BSON_Document, offsetSet)
@@ -552,7 +558,7 @@ zval* php_phongo_document_read_property(phongo_compat_object_handler_type* objec
552558

553559
PHONGO_COMPAT_PROPERTY_ACCESSOR_NAME_TO_STRING(member, key, key_len);
554560

555-
if (!php_phongo_document_get(intern, key, key_len, rv)) {
561+
if (!php_phongo_document_get(intern, key, key_len, rv, type == BP_VAR_IS)) {
556562
// Exception already thrown
557563
return &EG(uninitialized_zval);
558564
}
@@ -591,11 +597,16 @@ zval* php_phongo_document_read_dimension(phongo_compat_object_handler_type* obje
591597
intern = Z_OBJ_DOCUMENT(PHONGO_COMPAT_GET_OBJ(object));
592598

593599
if (Z_TYPE_P(offset) != IS_STRING) {
600+
if (type == BP_VAR_IS) {
601+
ZVAL_NULL(rv);
602+
return rv;
603+
}
604+
594605
phongo_throw_exception(PHONGO_ERROR_RUNTIME, "Could not find key of type \"%s\" in BSON document", PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(offset));
595606
return &EG(uninitialized_zval);
596607
}
597608

598-
if (!php_phongo_document_get(intern, Z_STRVAL_P(offset), Z_STRLEN_P(offset), rv)) {
609+
if (!php_phongo_document_get(intern, Z_STRVAL_P(offset), Z_STRLEN_P(offset), rv, type == BP_VAR_IS)) {
599610
// Exception already thrown
600611
return &EG(uninitialized_zval);
601612
}
@@ -615,7 +626,6 @@ int php_phongo_document_has_dimension(phongo_compat_object_handler_type* object,
615626
intern = Z_OBJ_DOCUMENT(PHONGO_COMPAT_GET_OBJ(object));
616627

617628
if (Z_TYPE_P(member) != IS_STRING) {
618-
phongo_throw_exception(PHONGO_ERROR_RUNTIME, "Could not find key of type \"%s\" in BSON document", PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(member));
619629
return false;
620630
}
621631

src/BSON/Document.stub.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,37 +45,37 @@ final public function toCanonicalExtendedJSON(): string {}
4545
final public function toRelaxedExtendedJSON(): string {}
4646

4747
#if PHP_VERSION_ID >= 80000
48-
public function offsetExists(mixed $key): bool {}
48+
public function offsetExists(mixed $offset): bool {}
4949
# else
50-
/** @param mixed $key */
51-
public function offsetExists($key): bool {}
50+
/** @param mixed $offset */
51+
public function offsetExists($offset): bool {}
5252
# endif
5353

5454
#if PHP_VERSION_ID >= 80000
55-
public function offsetGet(mixed $key): mixed {}
55+
public function offsetGet(mixed $offset): mixed {}
5656
# else
5757
/**
58-
* @param mixed $key
58+
* @param mixed $offset
5959
* @return mixed
6060
*/
61-
public function offsetGet($key) {}
61+
public function offsetGet($offset) {}
6262
# endif
6363

6464
#if PHP_VERSION_ID >= 80000
65-
public function offsetSet(mixed $key, mixed $value): void {}
65+
public function offsetSet(mixed $offset, mixed $value): void {}
6666
# else
6767
/**
68-
* @param mixed $key
68+
* @param mixed $offset
6969
* @param mixed $value
7070
*/
71-
public function offsetSet($key, $value): void {}
71+
public function offsetSet($offset, $value): void {}
7272
# endif
7373

7474
#if PHP_VERSION_ID >= 80000
75-
public function offsetUnset(mixed $key): void {}
75+
public function offsetUnset(mixed $offset): void {}
7676
# else
77-
/** @param mixed $key */
78-
public function offsetUnset($key): void {}
77+
/** @param mixed $offset */
78+
public function offsetUnset($offset): void {}
7979
# endif
8080

8181
final public function __toString(): string {}

src/BSON/Document_arginfo.h

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

src/BSON/PackedArray.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <php.h>
1818
#include <ext/standard/base64.h>
1919
#include <Zend/zend_interfaces.h>
20+
#include <Zend/zend_exceptions.h>
2021
#include <Zend/zend_operators.h>
2122
#include <ext/standard/php_var.h>
2223
#include <zend_smart_str.h>
@@ -117,7 +118,7 @@ static bool seek_iter_to_index(bson_iter_t* iter, zend_long index)
117118
return true;
118119
}
119120

120-
static bool php_phongo_packedarray_get(php_phongo_packedarray_t* intern, zend_long index, zval* return_value)
121+
static bool php_phongo_packedarray_get(php_phongo_packedarray_t* intern, zend_long index, zval* return_value, bool null_if_missing)
121122
{
122123
bson_iter_t iter;
123124

@@ -127,6 +128,11 @@ static bool php_phongo_packedarray_get(php_phongo_packedarray_t* intern, zend_lo
127128
}
128129

129130
if (!seek_iter_to_index(&iter, index)) {
131+
if (null_if_missing) {
132+
ZVAL_NULL(return_value);
133+
return true;
134+
}
135+
130136
phongo_throw_exception(PHONGO_ERROR_RUNTIME, "Could not find index \"%d\" in BSON array", index);
131137
return false;
132138
}
@@ -147,7 +153,7 @@ static PHP_METHOD(MongoDB_BSON_PackedArray, get)
147153

148154
intern = Z_PACKEDARRAY_OBJ_P(getThis());
149155

150-
if (!php_phongo_packedarray_get(intern, index, return_value)) {
156+
if (!php_phongo_packedarray_get(intern, index, return_value, false)) {
151157
// Exception already thrown
152158
RETURN_NULL();
153159
}
@@ -254,7 +260,7 @@ static PHP_METHOD(MongoDB_BSON_PackedArray, offsetGet)
254260
}
255261

256262
// May throw, in which case we do nothing
257-
php_phongo_packedarray_get(intern, Z_LVAL_P(key), return_value);
263+
php_phongo_packedarray_get(intern, Z_LVAL_P(key), return_value, false);
258264
}
259265

260266
static PHP_METHOD(MongoDB_BSON_PackedArray, offsetSet)
@@ -477,11 +483,16 @@ zval* php_phongo_packedarray_read_dimension(phongo_compat_object_handler_type* o
477483
intern = Z_OBJ_PACKEDARRAY(PHONGO_COMPAT_GET_OBJ(object));
478484

479485
if (Z_TYPE_P(offset) != IS_LONG) {
486+
if (type == BP_VAR_IS) {
487+
ZVAL_NULL(rv);
488+
return rv;
489+
}
490+
480491
phongo_throw_exception(PHONGO_ERROR_RUNTIME, "Could not find index of type \"%s\" in BSON array", PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(offset));
481492
return &EG(uninitialized_zval);
482493
}
483494

484-
if (!php_phongo_packedarray_get(intern, Z_LVAL_P(offset), rv)) {
495+
if (!php_phongo_packedarray_get(intern, Z_LVAL_P(offset), rv, type == BP_VAR_IS)) {
485496
// Exception already thrown
486497
return &EG(uninitialized_zval);
487498
}

src/BSON/PackedArray.stub.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,37 +32,37 @@ final public function toPHP(?array $typeMap = null) {}
3232
#endif
3333

3434
#if PHP_VERSION_ID >= 80000
35-
public function offsetExists(mixed $key): bool {}
35+
public function offsetExists(mixed $offset): bool {}
3636
# else
37-
/** @param mixed $key */
38-
public function offsetExists($key): bool {}
37+
/** @param mixed $offset */
38+
public function offsetExists($offset): bool {}
3939
# endif
4040

4141
#if PHP_VERSION_ID >= 80000
42-
public function offsetGet(mixed $key): mixed {}
42+
public function offsetGet(mixed $offset): mixed {}
4343
# else
4444
/**
45-
* @param mixed $key
45+
* @param mixed $offset
4646
* @return mixed
4747
*/
48-
public function offsetGet($key) {}
48+
public function offsetGet($offset) {}
4949
# endif
5050

5151
#if PHP_VERSION_ID >= 80000
52-
public function offsetSet(mixed $key, mixed $value): void {}
52+
public function offsetSet(mixed $offset, mixed $value): void {}
5353
# else
5454
/**
55-
* @param mixed $key
55+
* @param mixed $offset
5656
* @param mixed $value
5757
*/
58-
public function offsetSet($key, $value): void {}
58+
public function offsetSet($offset, $value): void {}
5959
# endif
6060

6161
#if PHP_VERSION_ID >= 80000
62-
public function offsetUnset(mixed $key): void {}
62+
public function offsetUnset(mixed $offset): void {}
6363
# else
64-
/** @param mixed $key */
65-
public function offsetUnset($key): void {}
64+
/** @param mixed $offset */
65+
public function offsetUnset($offset): void {}
6666
# endif
6767

6868
final public function __toString(): string {}

0 commit comments

Comments
 (0)