Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
ee91ccf4
Unverified
Commit
ee91ccf4
authored
Mar 30, 2020
by
Andreas Braun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-539: Rework client-side error logic for unacknowledged findAndModify
parent
79b828ea
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
1 deletion
+20
-1
FindAndModify.php
src/Operation/FindAndModify.php
+20
-1
No files found.
src/Operation/FindAndModify.php
View file @
ee91ccf4
...
@@ -55,6 +55,9 @@ class FindAndModify implements Executable, Explainable
...
@@ -55,6 +55,9 @@ class FindAndModify implements Executable, Explainable
/** @var integer */
/** @var integer */
private
static
$wireVersionForDocumentLevelValidation
=
4
;
private
static
$wireVersionForDocumentLevelValidation
=
4
;
/** @var integer */
private
static
$wireVersionForHint
=
9
;
/** @var integer */
/** @var integer */
private
static
$wireVersionForHintServerSideError
=
8
;
private
static
$wireVersionForHintServerSideError
=
8
;
...
@@ -245,7 +248,7 @@ class FindAndModify implements Executable, Explainable
...
@@ -245,7 +248,7 @@ class FindAndModify implements Executable, Explainable
* options (SERVER-40005), but the CRUD spec requires client-side errors
* options (SERVER-40005), but the CRUD spec requires client-side errors
* for server versions < 4.2. For later versions, we'll rely on the
* for server versions < 4.2. For later versions, we'll rely on the
* server to either utilize the option or report its own error. */
* server to either utilize the option or report its own error. */
if
(
isset
(
$this
->
options
[
'hint'
])
&&
!
server_supports_feature
(
$server
,
self
::
$wireVersionForHintServerSideErro
r
))
{
if
(
isset
(
$this
->
options
[
'hint'
])
&&
!
$this
->
isHintSupported
(
$serve
r
))
{
throw
UnsupportedException
::
hintNotSupported
();
throw
UnsupportedException
::
hintNotSupported
();
}
}
...
@@ -338,4 +341,20 @@ class FindAndModify implements Executable, Explainable
...
@@ -338,4 +341,20 @@ class FindAndModify implements Executable, Explainable
return
$options
;
return
$options
;
}
}
private
function
isAcknowledgedWriteConcern
()
:
bool
{
if
(
!
isset
(
$this
->
options
[
'writeConcern'
]))
{
return
true
;
}
return
$this
->
options
[
'writeConcern'
]
->
getW
()
>
1
||
$this
->
options
[
'writeConcern'
]
->
getJournal
();
}
private
function
isHintSupported
(
Server
$server
)
:
bool
{
$requiredWireVersion
=
$this
->
isAcknowledgedWriteConcern
()
?
self
::
$wireVersionForHintServerSideError
:
self
::
$wireVersionForHint
;
return
server_supports_feature
(
$server
,
$requiredWireVersion
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment