@@ -89,28 +89,6 @@ public static function createConnection($servers, array $options = array())
89
89
$ client = new \Memcached ($ options ['persistent_id ' ]);
90
90
$ username = $ options ['username ' ];
91
91
$ password = $ options ['password ' ];
92
- unset($ options ['persistent_id ' ], $ options ['username ' ], $ options ['password ' ]);
93
- $ options = array_change_key_case ($ options , CASE_UPPER );
94
-
95
- // set client's options
96
- $ client ->setOption (\Memcached::OPT_BINARY_PROTOCOL , true );
97
- $ client ->setOption (\Memcached::OPT_NO_BLOCK , true );
98
- if (!array_key_exists ('LIBKETAMA_COMPATIBLE ' , $ options ) && !array_key_exists (\Memcached::OPT_LIBKETAMA_COMPATIBLE , $ options )) {
99
- $ client ->setOption (\Memcached::OPT_LIBKETAMA_COMPATIBLE , true );
100
- }
101
- foreach ($ options as $ name => $ value ) {
102
- if (is_int ($ name )) {
103
- continue ;
104
- }
105
- if ('HASH ' === $ name || 'SERIALIZER ' === $ name || 'DISTRIBUTION ' === $ name ) {
106
- $ value = constant ('Memcached:: ' .$ name .'_ ' .strtoupper ($ value ));
107
- }
108
- $ opt = constant ('Memcached::OPT_ ' .$ name );
109
-
110
- unset($ options [$ name ]);
111
- $ options [$ opt ] = $ value ;
112
- }
113
- $ client ->setOptions ($ options );
114
92
115
93
// parse any DSN in $servers
116
94
foreach ($ servers as $ i => $ dsn ) {
@@ -145,11 +123,34 @@ public static function createConnection($servers, array $options = array())
145
123
if (isset ($ params ['query ' ])) {
146
124
parse_str ($ params ['query ' ], $ query );
147
125
$ params += $ query ;
126
+ $ options = $ query + $ options ;
148
127
}
149
128
150
129
$ servers [$ i ] = array ($ params ['host ' ], $ params ['port ' ], $ params ['weight ' ]);
151
130
}
152
131
132
+ // set client's options
133
+ unset($ options ['persistent_id ' ], $ options ['username ' ], $ options ['password ' ], $ options ['weight ' ]);
134
+ $ options = array_change_key_case ($ options , CASE_UPPER );
135
+ $ client ->setOption (\Memcached::OPT_BINARY_PROTOCOL , true );
136
+ $ client ->setOption (\Memcached::OPT_NO_BLOCK , true );
137
+ if (!array_key_exists ('LIBKETAMA_COMPATIBLE ' , $ options ) && !array_key_exists (\Memcached::OPT_LIBKETAMA_COMPATIBLE , $ options )) {
138
+ $ client ->setOption (\Memcached::OPT_LIBKETAMA_COMPATIBLE , true );
139
+ }
140
+ foreach ($ options as $ name => $ value ) {
141
+ if (is_int ($ name )) {
142
+ continue ;
143
+ }
144
+ if ('HASH ' === $ name || 'SERIALIZER ' === $ name || 'DISTRIBUTION ' === $ name ) {
145
+ $ value = constant ('Memcached:: ' .$ name .'_ ' .strtoupper ($ value ));
146
+ }
147
+ $ opt = constant ('Memcached::OPT_ ' .$ name );
148
+
149
+ unset($ options [$ name ]);
150
+ $ options [$ opt ] = $ value ;
151
+ }
152
+ $ client ->setOptions ($ options );
153
+
153
154
// set client's servers, taking care of persistent connections
154
155
if (!$ client ->isPristine ()) {
155
156
$ oldServers = array ();
0 commit comments