Skip to content

Commit 8060d72

Browse files
committed
Merge pull request #721
2 parents 68d4908 + 8e9c0d5 commit 8060d72

8 files changed

+54
-16
lines changed

.travis.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ cache:
2222

2323
env:
2424
global:
25-
- DRIVER_VERSION=1.7.0
25+
- DRIVER_VERSION=1.8.0
26+
# Todo: Remove when v1.8 has been branched
27+
- DRIVER_BRANCH="master"
2628
- SERVER_DISTRO=enterprise-ubuntu1604
2729
- SERVER_VERSION=4.2.0
2830
- DEPLOYMENT=STANDALONE
@@ -125,16 +127,18 @@ jobs:
125127
- DEPLOYMENT=SHARDED_CLUSTER_RS
126128

127129
# Test next patch release for driver
128-
- stage: Test
129-
php: "7.3"
130-
env:
131-
- DRIVER_BRANCH="v1.7"
130+
# Todo: enable when v1.8 has been branched
131+
# - stage: Test
132+
# php: "7.3"
133+
# env:
134+
# - DRIVER_BRANCH="v1.8"
132135

133136
# Test next minor release for driver
134-
- stage: Test
135-
php: "7.3"
136-
env:
137-
- DRIVER_BRANCH="master"
137+
# Todo: enable when v1.8 has been branched
138+
# - stage: Test
139+
# php: "7.3"
140+
# env:
141+
# - DRIVER_BRANCH="master"
138142

139143
before_install:
140144
- pip install "mongo-orchestration>=0.6.7,<1.0" --user `whoami`

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"php": "^7.0",
1414
"ext-hash": "*",
1515
"ext-json": "*",
16-
"ext-mongodb": "^1.7"
16+
"ext-mongodb": "^1.8"
1717
},
1818
"require-dev": {
1919
"phpunit/phpunit": "^6.4 || ^8.3",

docs/includes/apiargs-MongoDBCollection-method-find-option.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ operation: ~
4747
optional: true
4848
---
4949
arg_name: option
50+
name: allowDiskUse
51+
type: boolean
52+
description: |
53+
Enables writing to temporary files. When set to ``true``, queries can write
54+
data to the ``_tmp`` sub-directory in the ``dbPath`` directory. The default is
55+
``false``.
56+
interface: phpmethod
57+
operation: ~
58+
optional: true
59+
---
60+
arg_name: option
5061
name: batchSize
5162
type: integer
5263
description: |

docs/includes/apiargs-MongoDBCollection-method-findOne-option.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ source:
1010
file: apiargs-MongoDBCollection-method-find-option.yaml
1111
ref: skip
1212
---
13+
source:
14+
file: apiargs-MongoDBCollection-method-find-option.yaml
15+
ref: allowDiskUse
16+
---
1317
source:
1418
file: apiargs-MongoDBCollection-common-option.yaml
1519
ref: collation

docs/includes/apiargs-MongoDBGridFSBucket-method-find-option.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ source:
1414
file: apiargs-MongoDBCollection-method-find-option.yaml
1515
ref: limit
1616
---
17+
source:
18+
file: apiargs-MongoDBCollection-method-find-option.yaml
19+
ref: allowDiskUse
20+
---
1721
source:
1822
file: apiargs-MongoDBCollection-method-find-option.yaml
1923
ref: batchSize

docs/includes/apiargs-MongoDBGridFSBucket-method-findOne-option.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ source:
1010
file: apiargs-MongoDBCollection-method-find-option.yaml
1111
ref: skip
1212
---
13+
source:
14+
file: apiargs-MongoDBCollection-method-find-option.yaml
15+
ref: allowDiskUse
16+
---
1317
source:
1418
file: apiargs-MongoDBCollection-common-option.yaml
1519
ref: collation

src/Operation/Find.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ class Find implements Executable, Explainable
7272
*
7373
* Supported options:
7474
*
75+
* * allowDiskUse (boolean): Enables writing to temporary files. When set
76+
* to true, queries can write data to the _tmp sub-directory in the
77+
* dbPath directory. The default is false.
78+
*
7579
* * allowPartialResults (boolean): Get partial results from a mongos if
7680
* some shards are inaccessible (instead of throwing an error).
7781
*
@@ -169,6 +173,10 @@ public function __construct($databaseName, $collectionName, $filter, array $opti
169173
throw InvalidArgumentException::invalidType('$filter', $filter, 'array or object');
170174
}
171175

176+
if (isset($options['allowDiskUse']) && ! is_bool($options['allowDiskUse'])) {
177+
throw InvalidArgumentException::invalidType('"allowDiskUse" option', $options['allowDiskUse'], 'boolean');
178+
}
179+
172180
if (isset($options['allowPartialResults']) && ! is_bool($options['allowPartialResults'])) {
173181
throw InvalidArgumentException::invalidType('"allowPartialResults" option', $options['allowPartialResults'], 'boolean');
174182
}
@@ -416,7 +424,7 @@ private function createQueryOptions()
416424
}
417425
}
418426

419-
foreach (['allowPartialResults', 'batchSize', 'comment', 'hint', 'limit', 'maxAwaitTimeMS', 'maxScan', 'maxTimeMS', 'noCursorTimeout', 'oplogReplay', 'projection', 'readConcern', 'returnKey', 'showRecordId', 'skip', 'snapshot', 'sort'] as $option) {
427+
foreach (['allowDiskUse', 'allowPartialResults', 'batchSize', 'comment', 'hint', 'limit', 'maxAwaitTimeMS', 'maxScan', 'maxTimeMS', 'noCursorTimeout', 'oplogReplay', 'projection', 'readConcern', 'returnKey', 'showRecordId', 'skip', 'snapshot', 'sort'] as $option) {
420428
if (isset($this->options[$option])) {
421429
$options[$option] = $this->options[$option];
422430
}

tests/SpecTests/CrudSpecTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
class CrudSpecTest extends FunctionalTestCase
1616
{
1717
/** @var array */
18-
private static $incompleteTests = [
19-
'find-allowdiskuse: Find does not send allowDiskuse when value is not specified' => 'PHPLIB-500',
20-
'find-allowdiskuse: Find sends allowDiskuse false when false is specified' => 'PHPLIB-500',
21-
'find-allowdiskuse: Find sends allowDiskUse true when true is specified' => 'PHPLIB-500',
22-
];
18+
private static $incompleteTests = [];
2319

2420
/**
2521
* Assert that the expected and actual command documents match.
@@ -29,6 +25,13 @@ class CrudSpecTest extends FunctionalTestCase
2925
*/
3026
public static function assertCommandMatches(stdClass $expected, stdClass $actual)
3127
{
28+
foreach ($expected as $key => $value) {
29+
if ($value === null) {
30+
static::assertObjectNotHasAttribute($key, $actual);
31+
unset($expected->{$key});
32+
}
33+
}
34+
3235
static::assertDocumentsMatch($expected, $actual);
3336
}
3437

0 commit comments

Comments
 (0)