Skip to content

Commit 6651af0

Browse files
committed
[HttpFoundation] deprecate using with the legacy mongo extension; use it with the mongodb/mongodb package and ext-mongodb instead
1 parent d6b68e1 commit 6651af0

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

UPGRADE-3.4.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ HttpFoundation
234234
* `NativeSessionStorage::setSaveHandler()` now takes an instance of `\SessionHandlerInterface` as argument.
235235
Not passing it is deprecated and will throw a `TypeError` in 4.0.
236236

237+
* Using `Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler` with the legacy mongo extension
238+
has been deprecated and will be removed in 4.0. Use it with the mongodb/mongodb package and ext-mongodb instead.
239+
237240
HttpKernel
238241
----------
239242

UPGRADE-4.0.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,9 @@ HttpFoundation
540540

541541
* `NativeSessionStorage::setSaveHandler()` now requires an instance of `\SessionHandlerInterface` as argument.
542542

543+
* The `Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler` does not work with the legacy
544+
mongo extension anymore. It requires mongodb/mongodb package and ext-mongodb.
545+
543546
HttpKernel
544547
----------
545548

src/Symfony/Component/HttpFoundation/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CHANGELOG
77
* deprecated the `NativeSessionHandler` class,
88
* deprecated the `AbstractProxy`, `NativeProxy` and `SessionHandlerProxy` classes,
99
* deprecated setting session save handlers that do not implement `\SessionHandlerInterface` in `NativeSessionStorage::setSaveHandler()`
10+
* deprecated using `MongoDbSessionHandler` with the legacy mongo extension; use it with the mongodb/mongodb package and ext-mongodb instead
1011

1112
3.3.0
1213
-----

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
1313

1414
/**
15+
* Session handler using the mongodb/mongodb package and MongoDB driver extension.
16+
*
1517
* @author Markus Bachmann <[email protected]>
18+
*
19+
* @see https://packagist.org/packages/mongodb/mongodb
20+
* @see http://php.net/manual/en/set.mongodb.php
1621
*/
1722
class MongoDbSessionHandler implements \SessionHandlerInterface
1823
{
@@ -57,14 +62,18 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
5762
* If you use such an index, you can drop `gc_probability` to 0 since
5863
* no garbage-collection is required.
5964
*
60-
* @param \Mongo|\MongoClient|\MongoDB\Client $mongo A MongoDB\Client, MongoClient or Mongo instance
61-
* @param array $options An associative array of field options
65+
* @param \MongoDB\Client $mongo A MongoDB\Client instance
66+
* @param array $options An associative array of field options
6267
*
6368
* @throws \InvalidArgumentException When MongoClient or Mongo instance not provided
6469
* @throws \InvalidArgumentException When "database" or "collection" not provided
6570
*/
6671
public function __construct($mongo, array $options)
6772
{
73+
if ($mongo instanceof \MongoClient || $mongo instanceof \Mongo) {
74+
@trigger_error(sprintf('Using %s with the legacy mongo extension is deprecated as of 3.4 and will be removed in 4.0. Use it with the mongodb/mongodb package and ext-mongodb instead.', __CLASS__), E_USER_DEPRECATED);
75+
}
76+
6877
if (!($mongo instanceof \MongoDB\Client || $mongo instanceof \MongoClient || $mongo instanceof \Mongo)) {
6978
throw new \InvalidArgumentException('MongoClient or Mongo instance required');
7079
}

0 commit comments

Comments
 (0)