فهرست منبع

Fix read preference tags handling in MongoClient

Andreas Braun 8 سال پیش
والد
کامیت
5bb830c6f2
1فایلهای تغییر یافته به همراه8 افزوده شده و 7 حذف شده
  1. 8 7
      lib/Mongo/MongoClient.php

+ 8 - 7
lib/Mongo/MongoClient.php

@@ -86,6 +86,10 @@ class MongoClient
             $server = 'mongodb://' . self::DEFAULT_HOST . ':' . self::DEFAULT_PORT;
         }
 
+        if (isset($options['readPreferenceTags'])) {
+            $options['readPreferenceTags'] = [$this->getReadPreferenceTags($options['readPreferenceTags'])];
+        }
+
         $this->applyConnectionOptions($server, $options);
 
         $this->server = $server;
@@ -409,13 +413,10 @@ class MongoClient
             unset($options['wTimeout']);
         }
 
-        if (isset($options['readPreferenceTags'])) {
-            $options['readPreferenceTags'] = [$this->getReadPreferenceTags($options['readPreferenceTags'])];
-
-            // Special handling for readPreferenceTags which are merged
-            if (isset($urlOptions['readPreferenceTags'])) {
-                $options['readPreferenceTags'] = array_merge($urlOptions['readPreferenceTags'], $options['readPreferenceTags']);
-            }
+        // Special handling for readPreferenceTags which are merged
+        if (isset($options['readPreferenceTags']) && isset($urlOptions['readPreferenceTags'])) {
+            $options['readPreferenceTags'] = array_merge($urlOptions['readPreferenceTags'], $options['readPreferenceTags']);
+            unset($urlOptions['readPreferenceTags']);
         }
 
         $urlOptions = array_merge($urlOptions, $options);