Giter VIP home page Giter VIP logo

Comments (5)

alcaeus avatar alcaeus commented on July 21, 2024 1

Just a quick update since I actually planned to have this done over the weekend: I realized that parsing the query string of the connection URL is a bit more complicated since users may specify multiple values for readPreferenceTags. This is described in example 1 in the read preference documentation:

// Prefer the nearest server in the "east" data center, then a server in the
// "west" data center, and finally fall back to no tag set preference
$uri  = 'mongodb://rs1.example.com,rs2.example.com/';
$uri .= '?readPreference=nearest';
$uri .= '&readPreferenceTags=dc:east';
$uri .= '&readPreferenceTags=dc:west';
$uri .= '&readPreferenceTags=';

I discovered this when testing so I'll have to rewrite the functionality and manually parse the query string instead of relying on parse_str to do it. If this bug is posing a problem for you, I suggest not passing the readPreference via options or the URL string and instead call setReadPreference on the MongoClient instance after creating it.

from mongo-php-adapter.

alcaeus avatar alcaeus commented on July 21, 2024

Thanks for the report. You are correct, the options may be set using the connection URI as well as the options argument, so MongoClient::__construct would have to parse these and apply readPreference and writeConcern (and potentially other options) as well to make sure the return values are correct.

You can create a PR if you want, otherwise I'll get to work on it during the weekend.

from mongo-php-adapter.

damienalexandre avatar damienalexandre commented on July 21, 2024

Thanks for your answer, I'm not available this weekend so you can take the lead on it.

Some thoughts:

  • both the url and the params needs to be checked;
  • I didn't find the source but I think the params from the option array overwrite the ones from the url if present in both;
  • only some options were supported by the old client, see http://php.net/manual/en/mongoclient.construct.php for the full list (and maybe have the default values set too).

Thanks!

from mongo-php-adapter.

alcaeus avatar alcaeus commented on July 21, 2024

Apologies for the delay. I've created #116 which should fix your issues. Can you give it a test to confirm?

from mongo-php-adapter.

alcaeus avatar alcaeus commented on July 21, 2024

1.0.5 has been released, fixing this bug.

from mongo-php-adapter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.