Uploaded image for project: 'PHP Driver: Extension'
  1. PHP Driver: Extension
  2. PHPC-425

WriteConcern constructor should accept only integer and strings for $w, without casting

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.0.0-beta2
    • Affects Version/s: 1.0.0-beta1
    • Component/s: None
    • None

      Currently, WriteConcern checks if $w is a numeric string (with is_numeric_string(). If so, it considers it as the integer acknowledgement level. This is problematic, since the user could have a custom write concern that is a numeric string:

      REPLICASET:PRIMARY> conf.settings = { getLastErrorModes: { "2" : { "foo":1 }}}
      { "getLastErrorModes" : { "2" : { "foo" : 1 } } }
      REPLICASET:PRIMARY> conf.members[0].tags = { "foo":"bar"}
      { "foo" : "bar" }
      REPLICASET:PRIMARY> rs.reconfig(conf)
      { "ok" : 1 }
      REPLICASET:PRIMARY>
      

      I propose we change the zpp format to accept a zval, use integers and strings as-is (without any conversion), and throw InvalidArgumentException on other types.

            Assignee:
            jmikola@mongodb.com Jeremy Mikola
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: