Skip to content

Commit 0e1516b

Browse files
committed
Merge pull request #478
2 parents 0d84061 + d3ed4b0 commit 0e1516b

13 files changed

+14
-135
lines changed

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ description: |
1616
Specifies the initial batch size for the cursor. A batchSize of ``0`` means an
1717
empty first batch and is useful for quickly returning a cursor or failure
1818
message without doing significant server-side work.
19-
20-
.. note::
21-
22-
This is not supported for inline aggregation results (i.e. ``useCursor``
23-
option is ``false`` or the server version is < 2.6).
2419
interface: phpmethod
2520
operation: ~
2621
optional: true
@@ -83,12 +78,6 @@ type: boolean
8378
description: |
8479
Indicates whether the command will request that the server provide results
8580
using a cursor. The default is ``true``.
86-
87-
For MongoDB version 2.6 or later, ``useCursor`` allows users to turn off
88-
cursors if necessary to aid in replica set or shard cluster upgrades.
89-
90-
``useCursor`` is ignored for MongoDB versions prior to 2.6 as aggregation
91-
cursors are not available.
9281
interface: phpmethod
9382
operation: ~
9483
optional: true

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,8 @@ arg_name: option
6969
name: 2dsphereIndexVersion
7070
type: integer
7171
description: |
72-
Specifies the :manual:`version of a 2dsphere </core/2dsphere>` index to
73-
create.
74-
75-
MongoDB 2.6 introduced version 2 of 2dsphere indexes. Version 2 is the default
76-
version of 2dsphere indexes created in MongoDB 2.6 and later versions.
77-
``2dsphereIndexVersion`` enables you to override the default version 2.
72+
Overrides the server's default version for a :manual:`2dsphere
73+
</core/2dsphere>` index.
7874
interface: phpmethod
7975
operation: ~
8076
optional: true

docs/reference/method/MongoDBBulkWriteResult-getModifiedCount.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ Return Values
3737
The total number of documents that were modified by all update and replace
3838
operations in the bulk write.
3939

40-
The modified count is not available on versions of MongoDB before 2.6, which
41-
used the legacy wire protocol version (i.e. ``OP_UPDATE``). If this is the case,
42-
the modified count will be ``null``.
43-
4440
Errors/Exceptions
4541
-----------------
4642

docs/reference/method/MongoDBUpdateResult-getModifiedCount.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ Return Values
3535

3636
The number of documents that were modified.
3737

38-
The modified count is not available on versions of MongoDB before 2.6, which
39-
used the legacy wire protocol version (i.e. ``OP_UPDATE``). If this is the case,
40-
the modified count will be ``null``.
41-
4238
Errors/Exceptions
4339
-----------------
4440

src/Model/TypeMapArrayIterator.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@
2323
/**
2424
* Iterator for applying a type map to documents in inline command results.
2525
*
26-
* This iterator may be used to apply a type map to an array of documents
27-
* returned by a database command (e.g. aggregate on servers < 2.6) and allows
28-
* for functional equivalence with commands that return their results via a
29-
* cursor (e.g. aggregate on servers >= 2.6).
30-
*
3126
* @internal
3227
*/
3328
class TypeMapArrayIterator extends ArrayIterator

src/Operation/Aggregate.php

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
class Aggregate implements Executable
4242
{
4343
private static $wireVersionForCollation = 5;
44-
private static $wireVersionForCursor = 2;
4544
private static $wireVersionForDocumentLevelValidation = 4;
4645
private static $wireVersionForReadConcern = 4;
4746
private static $wireVersionForWriteConcern = 5;
@@ -100,11 +99,8 @@ class Aggregate implements Executable
10099
* * useCursor (boolean): Indicates whether the command will request that
101100
* the server provide results using a cursor. The default is true.
102101
*
103-
* For servers < 2.6, this option is ignored as aggregation cursors are
104-
* not available.
105-
*
106-
* For servers >= 2.6, this option allows users to turn off cursors if
107-
* necessary to aid in mongod/mongos upgrades.
102+
* This option allows users to turn off cursors if necessary to aid in
103+
* mongod/mongos upgrades.
108104
*
109105
* * writeConcern (MongoDB\Driver\WriteConcern): Write concern. This only
110106
* applies when the $out stage is specified.
@@ -238,16 +234,15 @@ public function execute(Server $server)
238234
}
239235

240236
$hasOutStage = \MongoDB\is_last_pipeline_operator_out($this->pipeline);
241-
$isCursorSupported = \MongoDB\server_supports_feature($server, self::$wireVersionForCursor);
242237

243-
$command = $this->createCommand($server, $isCursorSupported);
238+
$command = $this->createCommand($server);
244239
$options = $this->createOptions($hasOutStage);
245240

246241
$cursor = $hasOutStage
247242
? $server->executeReadWriteCommand($this->databaseName, $command, $options)
248243
: $server->executeReadCommand($this->databaseName, $command, $options);
249244

250-
if ($isCursorSupported && $this->options['useCursor']) {
245+
if ($this->options['useCursor']) {
251246
if (isset($this->options['typeMap'])) {
252247
$cursor->setTypeMap($this->options['typeMap']);
253248
}
@@ -272,22 +267,16 @@ public function execute(Server $server)
272267
* Create the aggregate command.
273268
*
274269
* @param Server $server
275-
* @param boolean $isCursorSupported
276270
* @return Command
277271
*/
278-
private function createCommand(Server $server, $isCursorSupported)
272+
private function createCommand(Server $server)
279273
{
280274
$cmd = [
281275
'aggregate' => $this->collectionName,
282276
'pipeline' => $this->pipeline,
283277
];
284278
$cmdOptions = [];
285279

286-
// Servers < 2.6 do not support any command options
287-
if ( ! $isCursorSupported) {
288-
return new Command($cmd);
289-
}
290-
291280
$cmd['allowDiskUse'] = $this->options['allowDiskUse'];
292281

293282
if (isset($this->options['bypassDocumentValidation']) && \MongoDB\server_supports_feature($server, self::$wireVersionForDocumentLevelValidation)) {

src/Operation/CreateIndexes.php

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
use MongoDB\Driver\Command;
2121
use MongoDB\Driver\Server;
22-
use MongoDB\Driver\BulkWrite as Bulk;
2322
use MongoDB\Driver\WriteConcern;
2423
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
2524
use MongoDB\Exception\InvalidArgumentException;
@@ -37,7 +36,6 @@
3736
class CreateIndexes implements Executable
3837
{
3938
private static $wireVersionForCollation = 5;
40-
private static $wireVersionForCommand = 2;
4139
private static $wireVersionForWriteConcern = 5;
4240

4341
private $databaseName;
@@ -115,9 +113,6 @@ public function __construct($databaseName, $collectionName, array $indexes, arra
115113
/**
116114
* Execute the operation.
117115
*
118-
* For servers < 2.6, this will actually perform an insert operation on the
119-
* database's "system.indexes" collection.
120-
*
121116
* @see Executable::execute()
122117
* @param Server $server
123118
* @return string[] The names of the created indexes
@@ -134,11 +129,7 @@ public function execute(Server $server)
134129
throw UnsupportedException::writeConcernNotSupported();
135130
}
136131

137-
if (\MongoDB\server_supports_feature($server, self::$wireVersionForCommand)) {
138-
$this->executeCommand($server);
139-
} else {
140-
$this->executeLegacy($server);
141-
}
132+
$this->executeCommand($server);
142133

143134
return array_map(function(IndexInput $index) { return (string) $index; }, $this->indexes);
144135
}
@@ -180,22 +171,4 @@ private function executeCommand(Server $server)
180171

181172
$server->executeWriteCommand($this->databaseName, new Command($cmd), $this->createOptions());
182173
}
183-
184-
/**
185-
* Create one or more indexes for the collection by inserting into the
186-
* "system.indexes" collection (MongoDB <2.6).
187-
*
188-
* @param Server $server
189-
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
190-
*/
191-
private function executeLegacy(Server $server)
192-
{
193-
$bulk = new Bulk(['ordered' => true]);
194-
195-
foreach ($this->indexes as $index) {
196-
$bulk->insert($index);
197-
}
198-
199-
$server->executeBulkWrite($this->databaseName . '.system.indexes', $bulk, new WriteConcern(1));
200-
}
201174
}

tests/DocumentationExamplesTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -712,10 +712,6 @@ public function testExample_42_50()
712712

713713
public function testExample_51_54()
714714
{
715-
if (version_compare($this->getServerVersion(), '2.6.0', '<')) {
716-
$this->markTestSkipped('$currentDate update operator is not supported');
717-
}
718-
719715
$db = new Database($this->manager, $this->getDatabaseName());
720716

721717
// Start Example 51

tests/Operation/AggregateFunctionalTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ function(stdClass $command) {
3030

3131
public function testDefaultWriteConcernIsOmitted()
3232
{
33-
if (version_compare($this->getServerVersion(), '2.6.0', '<')) {
34-
$this->markTestSkipped('$out pipeline operator is not supported');
35-
}
36-
3733
(new CommandObserver)->observe(
3834
function() {
3935
$operation = new Aggregate(

tests/Operation/BulkWriteFunctionalTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@
1212
class BulkWriteFunctionalTest extends FunctionalTestCase
1313
{
1414
private $collection;
15-
private $omitModifiedCount;
1615

1716
public function setUp()
1817
{
1918
parent::setUp();
2019

2120
$this->collection = new Collection($this->manager, $this->getDatabaseName(), $this->getCollectionName());
22-
$this->omitModifiedCount = version_compare($this->getServerVersion(), '2.6.0', '<');
2321
}
2422

2523
public function testInserts()
@@ -70,7 +68,7 @@ public function testUpdates()
7068

7169
$this->assertInstanceOf('MongoDB\BulkWriteResult', $result);
7270
$this->assertSame(5, $result->getMatchedCount());
73-
$this->omitModifiedCount or $this->assertSame(5, $result->getModifiedCount());
71+
$this->assertSame(5, $result->getModifiedCount());
7472
$this->assertSame(2, $result->getUpsertedCount());
7573

7674
$upsertedIds = $result->getUpsertedIds();
@@ -132,7 +130,7 @@ public function testMixedOrderedOperations()
132130
$this->assertSame([2 => 4], $result->getInsertedIds());
133131

134132
$this->assertSame(3, $result->getMatchedCount());
135-
$this->omitModifiedCount or $this->assertSame(3, $result->getModifiedCount());
133+
$this->assertSame(3, $result->getModifiedCount());
136134
$this->assertSame(1, $result->getUpsertedCount());
137135
$this->assertSame([4 => 4], $result->getUpsertedIds());
138136

0 commit comments

Comments
 (0)