@@ -209,7 +209,7 @@ public function aggregate(array $pipeline, array $options = [])
209
209
if ( ! isset ($ options ['readConcern ' ]) &&
210
210
! ($ hasOutStage && $ this ->readConcern ->getLevel () === ReadConcern::MAJORITY ) &&
211
211
\MongoDB \server_supports_feature ($ server , self ::$ wireVersionForReadConcern ) &&
212
- ! $ this -> isInTransaction ($ options )) {
212
+ ! \ MongoDB \is_in_transaction ($ options )) {
213
213
$ options ['readConcern ' ] = $ this ->readConcern ;
214
214
}
215
215
@@ -220,7 +220,7 @@ public function aggregate(array $pipeline, array $options = [])
220
220
if ($ hasOutStage &&
221
221
! isset ($ options ['writeConcern ' ]) &&
222
222
\MongoDB \server_supports_feature ($ server , self ::$ wireVersionForWritableCommandWriteConcern ) &&
223
- ! $ this -> isInTransaction ($ options )) {
223
+ ! \ MongoDB \is_in_transaction ($ options )) {
224
224
$ options ['writeConcern ' ] = $ this ->writeConcern ;
225
225
}
226
226
@@ -242,7 +242,7 @@ public function aggregate(array $pipeline, array $options = [])
242
242
*/
243
243
public function bulkWrite (array $ operations , array $ options = [])
244
244
{
245
- if ( ! isset ($ options ['writeConcern ' ]) && ! $ this -> isInTransaction ($ options )) {
245
+ if ( ! isset ($ options ['writeConcern ' ]) && ! \ MongoDB \is_in_transaction ($ options )) {
246
246
$ options ['writeConcern ' ] = $ this ->writeConcern ;
247
247
}
248
248
@@ -274,7 +274,7 @@ public function count($filter = [], array $options = [])
274
274
275
275
$ server = $ this ->manager ->selectServer ($ options ['readPreference ' ]);
276
276
277
- if ( ! isset ($ options ['readConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForReadConcern ) && ! $ this -> isInTransaction ($ options )) {
277
+ if ( ! isset ($ options ['readConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForReadConcern ) && ! \ MongoDB \is_in_transaction ($ options )) {
278
278
$ options ['readConcern ' ] = $ this ->readConcern ;
279
279
}
280
280
@@ -303,7 +303,7 @@ public function countDocuments($filter = [], array $options = [])
303
303
304
304
$ server = $ this ->manager ->selectServer ($ options ['readPreference ' ]);
305
305
306
- if ( ! isset ($ options ['readConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForReadConcern ) && ! $ this -> isInTransaction ($ options )) {
306
+ if ( ! isset ($ options ['readConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForReadConcern ) && ! \ MongoDB \is_in_transaction ($ options )) {
307
307
$ options ['readConcern ' ] = $ this ->readConcern ;
308
308
}
309
309
@@ -365,7 +365,7 @@ public function createIndexes(array $indexes, array $options = [])
365
365
{
366
366
$ server = $ this ->manager ->selectServer (new ReadPreference (ReadPreference::RP_PRIMARY ));
367
367
368
- if ( ! isset ($ options ['writeConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForWritableCommandWriteConcern ) && ! $ this -> isInTransaction ($ options )) {
368
+ if ( ! isset ($ options ['writeConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForWritableCommandWriteConcern ) && ! \ MongoDB \is_in_transaction ($ options )) {
369
369
$ options ['writeConcern ' ] = $ this ->writeConcern ;
370
370
}
371
371
@@ -388,7 +388,7 @@ public function createIndexes(array $indexes, array $options = [])
388
388
*/
389
389
public function deleteMany ($ filter , array $ options = [])
390
390
{
391
- if ( ! isset ($ options ['writeConcern ' ]) && ! $ this -> isInTransaction ($ options )) {
391
+ if ( ! isset ($ options ['writeConcern ' ]) && ! \ MongoDB \is_in_transaction ($ options )) {
392
392
$ options ['writeConcern ' ] = $ this ->writeConcern ;
393
393
}
394
394
@@ -412,7 +412,7 @@ public function deleteMany($filter, array $options = [])
412
412
*/
413
413
public function deleteOne ($ filter , array $ options = [])
414
414
{
415
- if ( ! isset ($ options ['writeConcern ' ]) && ! $ this -> isInTransaction ($ options )) {
415
+ if ( ! isset ($ options ['writeConcern ' ]) && ! \ MongoDB \is_in_transaction ($ options )) {
416
416
$ options ['writeConcern ' ] = $ this ->writeConcern ;
417
417
}
418
418
@@ -443,7 +443,7 @@ public function distinct($fieldName, $filter = [], array $options = [])
443
443
444
444
$ server = $ this ->manager ->selectServer ($ options ['readPreference ' ]);
445
445
446
- if ( ! isset ($ options ['readConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForReadConcern ) && ! $ this -> isInTransaction ($ options )) {
446
+ if ( ! isset ($ options ['readConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForReadConcern ) && ! \ MongoDB \is_in_transaction ($ options )) {
447
447
$ options ['readConcern ' ] = $ this ->readConcern ;
448
448
}
449
449
@@ -470,7 +470,7 @@ public function drop(array $options = [])
470
470
471
471
$ server = $ this ->manager ->selectServer (new ReadPreference (ReadPreference::RP_PRIMARY ));
472
472
473
- if ( ! isset ($ options ['writeConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForWritableCommandWriteConcern ) && ! $ this -> isInTransaction ($ options )) {
473
+ if ( ! isset ($ options ['writeConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForWritableCommandWriteConcern ) && ! \ MongoDB \is_in_transaction ($ options )) {
474
474
$ options ['writeConcern ' ] = $ this ->writeConcern ;
475
475
}
476
476
@@ -504,7 +504,7 @@ public function dropIndex($indexName, array $options = [])
504
504
505
505
$ server = $ this ->manager ->selectServer (new ReadPreference (ReadPreference::RP_PRIMARY ));
506
506
507
- if ( ! isset ($ options ['writeConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForWritableCommandWriteConcern ) && ! $ this -> isInTransaction ($ options )) {
507
+ if ( ! isset ($ options ['writeConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForWritableCommandWriteConcern ) && ! \ MongoDB \is_in_transaction ($ options )) {
508
508
$ options ['writeConcern ' ] = $ this ->writeConcern ;
509
509
}
510
510
@@ -531,7 +531,7 @@ public function dropIndexes(array $options = [])
531
531
532
532
$ server = $ this ->manager ->selectServer (new ReadPreference (ReadPreference::RP_PRIMARY ));
533
533
534
- if ( ! isset ($ options ['writeConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForWritableCommandWriteConcern ) && ! $ this -> isInTransaction ($ options )) {
534
+ if ( ! isset ($ options ['writeConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForWritableCommandWriteConcern ) && ! \ MongoDB \is_in_transaction ($ options )) {
535
535
$ options ['writeConcern ' ] = $ this ->writeConcern ;
536
536
}
537
537
@@ -559,7 +559,7 @@ public function estimatedDocumentCount(array $options = [])
559
559
560
560
$ server = $ this ->manager ->selectServer ($ options ['readPreference ' ]);
561
561
562
- if ( ! isset ($ options ['readConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForReadConcern ) && ! $ this -> isInTransaction ($ options )) {
562
+ if ( ! isset ($ options ['readConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForReadConcern ) && ! \ MongoDB \is_in_transaction ($ options )) {
563
563
$ options ['readConcern ' ] = $ this ->readConcern ;
564
564
}
565
565
@@ -617,7 +617,7 @@ public function find($filter = [], array $options = [])
617
617
618
618
$ server = $ this ->manager ->selectServer ($ options ['readPreference ' ]);
619
619
620
- if ( ! isset ($ options ['readConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForReadConcern ) && ! $ this -> isInTransaction ($ options )) {
620
+ if ( ! isset ($ options ['readConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForReadConcern ) && ! \ MongoDB \is_in_transaction ($ options )) {
621
621
$ options ['readConcern ' ] = $ this ->readConcern ;
622
622
}
623
623
@@ -650,7 +650,7 @@ public function findOne($filter = [], array $options = [])
650
650
651
651
$ server = $ this ->manager ->selectServer ($ options ['readPreference ' ]);
652
652
653
- if ( ! isset ($ options ['readConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForReadConcern ) && ! $ this -> isInTransaction ($ options )) {
653
+ if ( ! isset ($ options ['readConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForReadConcern ) && ! \ MongoDB \is_in_transaction ($ options )) {
654
654
$ options ['readConcern ' ] = $ this ->readConcern ;
655
655
}
656
656
@@ -682,7 +682,7 @@ public function findOneAndDelete($filter, array $options = [])
682
682
{
683
683
$ server = $ this ->manager ->selectServer (new ReadPreference (ReadPreference::RP_PRIMARY ));
684
684
685
- if ( ! isset ($ options ['writeConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForFindAndModifyWriteConcern ) && ! $ this -> isInTransaction ($ options )) {
685
+ if ( ! isset ($ options ['writeConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForFindAndModifyWriteConcern ) && ! \ MongoDB \is_in_transaction ($ options )) {
686
686
$ options ['writeConcern ' ] = $ this ->writeConcern ;
687
687
}
688
688
@@ -719,7 +719,7 @@ public function findOneAndReplace($filter, $replacement, array $options = [])
719
719
{
720
720
$ server = $ this ->manager ->selectServer (new ReadPreference (ReadPreference::RP_PRIMARY ));
721
721
722
- if ( ! isset ($ options ['writeConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForFindAndModifyWriteConcern ) && ! $ this -> isInTransaction ($ options )) {
722
+ if ( ! isset ($ options ['writeConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForFindAndModifyWriteConcern ) && ! \ MongoDB \is_in_transaction ($ options )) {
723
723
$ options ['writeConcern ' ] = $ this ->writeConcern ;
724
724
}
725
725
@@ -756,7 +756,7 @@ public function findOneAndUpdate($filter, $update, array $options = [])
756
756
{
757
757
$ server = $ this ->manager ->selectServer (new ReadPreference (ReadPreference::RP_PRIMARY ));
758
758
759
- if ( ! isset ($ options ['writeConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForFindAndModifyWriteConcern ) && ! $ this -> isInTransaction ($ options )) {
759
+ if ( ! isset ($ options ['writeConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForFindAndModifyWriteConcern ) && ! \ MongoDB \is_in_transaction ($ options )) {
760
760
$ options ['writeConcern ' ] = $ this ->writeConcern ;
761
761
}
762
762
@@ -865,7 +865,7 @@ public function getWriteConcern()
865
865
*/
866
866
public function insertMany (array $ documents , array $ options = [])
867
867
{
868
- if ( ! isset ($ options ['writeConcern ' ]) && ! $ this -> isInTransaction ($ options )) {
868
+ if ( ! isset ($ options ['writeConcern ' ]) && ! \ MongoDB \is_in_transaction ($ options )) {
869
869
$ options ['writeConcern ' ] = $ this ->writeConcern ;
870
870
}
871
871
@@ -888,7 +888,7 @@ public function insertMany(array $documents, array $options = [])
888
888
*/
889
889
public function insertOne ($ document , array $ options = [])
890
890
{
891
- if ( ! isset ($ options ['writeConcern ' ]) && ! $ this -> isInTransaction ($ options )) {
891
+ if ( ! isset ($ options ['writeConcern ' ]) && ! \ MongoDB \is_in_transaction ($ options )) {
892
892
$ options ['writeConcern ' ] = $ this ->writeConcern ;
893
893
}
894
894
@@ -950,15 +950,15 @@ public function mapReduce(JavascriptInterface $map, JavascriptInterface $reduce,
950
950
*
951
951
* A read concern is also not compatible with transactions.
952
952
*/
953
- if ( ! isset ($ options ['readConcern ' ]) && ! ($ hasOutputCollection && $ this ->readConcern ->getLevel () === ReadConcern::MAJORITY ) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForReadConcern ) && ! $ this -> isInTransaction ($ options )) {
953
+ if ( ! isset ($ options ['readConcern ' ]) && ! ($ hasOutputCollection && $ this ->readConcern ->getLevel () === ReadConcern::MAJORITY ) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForReadConcern ) && ! \ MongoDB \is_in_transaction ($ options )) {
954
954
$ options ['readConcern ' ] = $ this ->readConcern ;
955
955
}
956
956
957
957
if ( ! isset ($ options ['typeMap ' ])) {
958
958
$ options ['typeMap ' ] = $ this ->typeMap ;
959
959
}
960
960
961
- if ( ! isset ($ options ['writeConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForWritableCommandWriteConcern ) && ! $ this -> isInTransaction ($ options )) {
961
+ if ( ! isset ($ options ['writeConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForWritableCommandWriteConcern ) && ! \ MongoDB \is_in_transaction ($ options )) {
962
962
$ options ['writeConcern ' ] = $ this ->writeConcern ;
963
963
}
964
964
@@ -982,7 +982,7 @@ public function mapReduce(JavascriptInterface $map, JavascriptInterface $reduce,
982
982
*/
983
983
public function replaceOne ($ filter , $ replacement , array $ options = [])
984
984
{
985
- if ( ! isset ($ options ['writeConcern ' ]) && ! $ this -> isInTransaction ($ options )) {
985
+ if ( ! isset ($ options ['writeConcern ' ]) && ! \ MongoDB \is_in_transaction ($ options )) {
986
986
$ options ['writeConcern ' ] = $ this ->writeConcern ;
987
987
}
988
988
@@ -1007,7 +1007,7 @@ public function replaceOne($filter, $replacement, array $options = [])
1007
1007
*/
1008
1008
public function updateMany ($ filter , $ update , array $ options = [])
1009
1009
{
1010
- if ( ! isset ($ options ['writeConcern ' ]) && ! $ this -> isInTransaction ($ options )) {
1010
+ if ( ! isset ($ options ['writeConcern ' ]) && ! \ MongoDB \is_in_transaction ($ options )) {
1011
1011
$ options ['writeConcern ' ] = $ this ->writeConcern ;
1012
1012
}
1013
1013
@@ -1032,7 +1032,7 @@ public function updateMany($filter, $update, array $options = [])
1032
1032
*/
1033
1033
public function updateOne ($ filter , $ update , array $ options = [])
1034
1034
{
1035
- if ( ! isset ($ options ['writeConcern ' ]) && ! $ this -> isInTransaction ($ options )) {
1035
+ if ( ! isset ($ options ['writeConcern ' ]) && ! \ MongoDB \is_in_transaction ($ options )) {
1036
1036
$ options ['writeConcern ' ] = $ this ->writeConcern ;
1037
1037
}
1038
1038
@@ -1066,7 +1066,7 @@ public function watch(array $pipeline = [], array $options = [])
1066
1066
* related to change streams being unsupported instead of an
1067
1067
* UnsupportedException regarding use of the "readConcern" option from
1068
1068
* the Aggregate operation class. */
1069
- if ( ! isset ($ options ['readConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForReadConcern ) && ! $ this -> isInTransaction ($ options )) {
1069
+ if ( ! isset ($ options ['readConcern ' ]) && \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForReadConcern ) && ! \ MongoDB \is_in_transaction ($ options )) {
1070
1070
$ options ['readConcern ' ] = $ this ->readConcern ;
1071
1071
}
1072
1072
@@ -1098,18 +1098,4 @@ public function withOptions(array $options = [])
1098
1098
1099
1099
return new Collection ($ this ->manager , $ this ->databaseName , $ this ->collectionName , $ options );
1100
1100
}
1101
-
1102
- /**
1103
- * Returns whether we are currently in a transaction
1104
- *
1105
- * @param array $options Command options
1106
- * @return bool
1107
- */
1108
- private function isInTransaction (array $ options )
1109
- {
1110
- if (isset ($ options ['session ' ]) && $ options ['session ' ] instanceof \MongoDB \Driver \Session && $ options ['session ' ]->isInTransaction ()) {
1111
- return true ;
1112
- }
1113
- return false ;
1114
- }
1115
1101
}
0 commit comments