You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class MongoDbStore implements PersistingStoreInterface
49
54
{
50
55
use ExpiringStoreTrait;
51
56
52
-
privateCollection$collection;
53
-
privateClient$client;
57
+
privateManager$manager;
58
+
privatestring$namespace;
54
59
privatestring$uri;
55
60
privatearray$options;
56
61
privatefloat$initialTtl;
57
62
58
63
/**
59
-
* @param Collection|Client|string $mongo An instance of a Collection or Client or URI @see https://docs.mongodb.com/manual/reference/connection-string/
60
-
* @param array $options See below
61
-
* @param float $initialTtl The expiration delay of locks in seconds
64
+
* @param Collection|Client|Manager|string $mongo An instance of a Collection or Client or URI @see https://docs.mongodb.com/manual/reference/connection-string/
65
+
* @param array $options See below
66
+
* @param float $initialTtl The expiration delay of locks in seconds
62
67
*
63
68
* @throws InvalidArgumentException If required options are not provided
64
69
* @throws InvalidTtlException When the initial ttl is not valid
@@ -88,7 +93,7 @@ class MongoDbStore implements PersistingStoreInterface
trigger_deprecation('symfony/lock', '6.3', 'The "gcProbablity" option (notice the typo in its name) is deprecated in "%s"; use the "gcProbability" option instead.', __CLASS__);
@@ -108,21 +113,27 @@ public function __construct(Collection|Client|string $mongo, array $options = []
if ($this->options['gcProbability'] < 0.0 || $this->options['gcProbability'] > 1.0) {
128
139
thrownewInvalidArgumentException(sprintf('"%s()" gcProbability must be a float from 0.0 to 1.0, "%f" given.', __METHOD__, $this->options['gcProbability']));
@@ -142,6 +153,10 @@ public function __construct(Collection|Client|string $mongo, array $options = []
142
153
*/
143
154
privatefunctionskimUri(string$uri): string
144
155
{
156
+
if (!str_starts_with($uri, 'mongodb://') && !str_starts_with($uri, 'mongodb+srv://')) {
157
+
thrownewInvalidArgumentException(sprintf('The given MongoDB Connection URI "%s" is invalid. Expecting "mongodb://" or "mongodb+srv://".', $uri));
158
+
}
159
+
145
160
if (false === $parsedUrl = parse_url($uri)) {
146
161
thrownewInvalidArgumentException(sprintf('The given MongoDB Connection URI "%s" is invalid.', $uri));
147
162
}
@@ -195,14 +210,19 @@ private function skimUri(string $uri): string
0 commit comments