File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,9 @@ class FindAndModify implements Executable, Explainable
55
55
/** @var integer */
56
56
private static $ wireVersionForDocumentLevelValidation = 4 ;
57
57
58
+ /** @var integer */
59
+ private static $ wireVersionForHint = 9 ;
60
+
58
61
/** @var integer */
59
62
private static $ wireVersionForHintServerSideError = 8 ;
60
63
@@ -245,7 +248,7 @@ public function execute(Server $server)
245
248
* options (SERVER-40005), but the CRUD spec requires client-side errors
246
249
* for server versions < 4.2. For later versions, we'll rely on the
247
250
* server to either utilize the option or report its own error. */
248
- if (isset ($ this ->options ['hint ' ]) && ! server_supports_feature ($ server, self :: $ wireVersionForHintServerSideError )) {
251
+ if (isset ($ this ->options ['hint ' ]) && ! $ this -> isHintSupported ($ server )) {
249
252
throw UnsupportedException::hintNotSupported ();
250
253
}
251
254
@@ -338,4 +341,20 @@ private function createOptions()
338
341
339
342
return $ options ;
340
343
}
344
+
345
+ private function isAcknowledgedWriteConcern () : bool
346
+ {
347
+ if (! isset ($ this ->options ['writeConcern ' ])) {
348
+ return true ;
349
+ }
350
+
351
+ return $ this ->options ['writeConcern ' ]->getW () > 1 || $ this ->options ['writeConcern ' ]->getJournal ();
352
+ }
353
+
354
+ private function isHintSupported (Server $ server ) : bool
355
+ {
356
+ $ requiredWireVersion = $ this ->isAcknowledgedWriteConcern () ? self ::$ wireVersionForHintServerSideError : self ::$ wireVersionForHint ;
357
+
358
+ return server_supports_feature ($ server , $ requiredWireVersion );
359
+ }
341
360
}
You can’t perform that action at this time.
0 commit comments