[HttpFoundation] MongoDB driver support for sessions #18788
Status: Needs work |
what am i doing wrong why cant i pass fabbot.io :/ |
@@ -69,7 +69,7 @@ class MongoDbSessionHandler implements \SessionHandlerInterface | |||
*/ | |||
public function __construct($mongo, array $options) | |||
{ | |||
if (!($mongo instanceof \MongoClient || $mongo instanceof \Mongo)) { | |||
if (!($mongo instanceof \MongoClient || $mongo instanceof \Mongo || $mongo instanceof \MongoDB\Client)) { | |||
throw new \InvalidArgumentException('MongoClient or Mongo instance required'); |
There was a problem hiding this comment.
Should add the new case here as well
There was a problem hiding this comment.
$mongo instanceof \MongoDB\Client
-> MongoDB is available
any alternatives ?
throw new \InvalidArgumentException('MongoClient or Mongo instance required'); | ||
if (!($mongo instanceof \MongoClient || $mongo instanceof \Mongo || $mongo instanceof \MongoDB\Client)) { | ||
throw new \InvalidArgumentException('MongoClient, Mongo or MongoDB instance required'); | ||
}elseif($mongo instanceof \MongoDB\Client && !class_exists('\MongoDB\Collection')){ |
There was a problem hiding this comment.
elseif
seems weird after throw an exception which is uncaught.
You need to respect CS in order to pass fabbot.io checks successfully. You can apply directly the patch proposed by the tool and push the changes again. |
500c71c
to
008ee4c
Compare
throw new \InvalidArgumentException('MongoClient or Mongo instance required'); | ||
if (!($mongo instanceof \MongoClient || $mongo instanceof \Mongo || $mongo instanceof \MongoDB\Client)) { | ||
throw new \InvalidArgumentException('MongoClient, Mongo or MongoDB instance required'); | ||
}elseif($mongo instanceof \MongoDB\Client && !class_exists('\MongoDB\Collection')){ |
There was a problem hiding this comment.
Please, put this check in a separated if
statement.
@xabbuh, do you know which version of PHP-CS-Fixer is fabbot.io using? I don't know how the current status of these changes could be passed the CS checks. |
patched : running php-cs-fixer-1.11 locally with --level=symfony |
'id_field' => '_id', | ||
'data_field' => 'data', | ||
'time_field' => 'time', | ||
'expiry_field' => 'expires_at', |
There was a problem hiding this comment.
Indentation should remain at 4 spaces
Is it possible to add some test cases to |
@@ -120,9 +129,15 @@ public function destroy($sessionId) | |||
*/ | |||
public function gc($maxlifetime) | |||
{ | |||
$this->getCollection()->remove(array( |
There was a problem hiding this comment.
what about doing this (same below and above)?
$collection = $this->getCollection();
$method = $collection instanceof \MongoDB\Collection ? 'deleteMany' : 'remove';
$collection->$method(array(
@funyx Can you finish this PR by taking comments into account? Thanks. |
Closing as there is no more feedback here and someone opened a similar one at #19186. |
Adding support for the new MongoDB php driver in the mongodb sessions' handler.
php-ref : MongoDB driver
mongo-ref : official mongo-php library