Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 35755a2

Browse filesBrowse files
committed
[Component][HttpFoundation][Session][Storage][Handler][MongoDbSessionHandler] Bug Fix - ref:http://mongodb.github.io/mongo-php-library/api/class-MongoDB.Collection.html
1 parent cedff47 commit 35755a2
Copy full SHA for 35755a2

File tree

1 file changed

+34
-11
lines changed
Filter options

1 file changed

+34
-11
lines changed

‎src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php
+34-11Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,16 @@ public function close()
108108
*/
109109
public function destroy($sessionId)
110110
{
111-
$this->getCollection()->deleteOne(array(
112-
$this->options['id_field'] => $sessionId,
113-
));
111+
if($this->getCollection() instanceof \MongoDB\Collection)
112+
{
113+
$this->getCollection()->deleteOne(array(
114+
$this->options['id_field'] => $sessionId,
115+
));
116+
}else{
117+
$this->getCollection()->remove(array(
118+
$this->options['id_field'] => $sessionId,
119+
));
120+
}
114121

115122
return true;
116123
}
@@ -120,9 +127,16 @@ public function destroy($sessionId)
120127
*/
121128
public function gc($maxlifetime)
122129
{
123-
$this->getCollection()->deleteMany(array(
124-
$this->options['expiry_field'] => array('$lt' => new \MongoDate()),
125-
));
130+
if($this->getCollection() instanceof \MongoDB\Collection)
131+
{
132+
$this->getCollection()->deleteMany(array(
133+
$this->options['id_field'] => $sessionId,
134+
));
135+
}else{
136+
$this->getCollection()->remove(array(
137+
$this->options['expiry_field'] => array('$lt' => new \MongoDate()),
138+
));
139+
}
126140

127141
return true;
128142
}
@@ -140,11 +154,20 @@ public function write($sessionId, $data)
140154
$this->options['expiry_field'] => $expiry,
141155
);
142156

143-
$this->getCollection()->updateOne(
144-
array($this->options['id_field'] => $sessionId),
145-
array('$set' => $fields),
146-
array('upsert' => true, 'multiple' => false)
147-
);
157+
if($this->getCollection() instanceof \MongoDB\Collection)
158+
{
159+
$this->getCollection()->updateOne(
160+
array($this->options['id_field'] => $sessionId),
161+
array('$set' => $fields),
162+
array('upsert' => true, 'multiple' => false)
163+
);
164+
}else{
165+
$this->getCollection()->update(
166+
array($this->options['id_field'] => $sessionId),
167+
array('$set' => $fields),
168+
array('upsert' => true, 'multiple' => false)
169+
);
170+
}
148171

149172
return true;
150173
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.