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
5555 /** @var integer */
5656 private static $ wireVersionForDocumentLevelValidation = 4 ;
5757
58+ /** @var integer */
59+ private static $ wireVersionForHint = 9 ;
60+
5861 /** @var integer */
5962 private static $ wireVersionForHintServerSideError = 8 ;
6063
@@ -245,7 +248,7 @@ public function execute(Server $server)
245248 * options (SERVER-40005), but the CRUD spec requires client-side errors
246249 * for server versions < 4.2. For later versions, we'll rely on the
247250 * 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 )) {
249252 throw UnsupportedException::hintNotSupported ();
250253 }
251254
@@ -338,4 +341,20 @@ private function createOptions()
338341
339342 return $ options ;
340343 }
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+ }
341360}
You can’t perform that action at this time.
0 commit comments