-
Type:
Improvement
-
Resolution: Done
-
Priority:
Minor - P4
-
Affects Version/s: 2.2.1
-
Component/s: Replication
-
None
-
3
-
None
-
None
-
None
-
None
-
None
-
None
While looking at implementing the new "w=1" default setting for MongoClient I noticed that setting values for w sometimes shows a confusing warning. This also cause the confusion in PHP-556 and https://github.com/doctrine/mongodb-odm/pull/439#issuecomment-9871420.
Right now, when you send a w value of anything but int(0), int(1), bool(false) or bool(true) with getLastError and replication is not enabled, you receive a warning message back from mongod: "no replication has been enabled, so w=2+ won't work".
If however you (incorrectly) specify as getLastError value, string(true) or string(false) then you will get the same error message. From the PHP driver, we do not handle different string values differently because getLastErrorModes, and we should not use string(false) and string(true) as magical keywords to actually mean bool(false) and bool(true). It would be a useful improvement if the error message from mongod would include the real value of "w" that it received, instead of just using "w=2+" all the time. For example:
- "no replication enabled, so w=3 won't work"
- "no replication enabled, so w="allDCs" won't work"
- "no replication enabled, so w="true" won't work"