-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Environment:PHP7.0.0-RC3, Debian 8.1
When the Manager object is used and passed to other classes (e.g. when wrapped in a Singleton class, or the class that created the object is passed as $this), a SIGSEGV will happen in PHP.
Repro case:
<?php use MongoDB\Driver\Manager; use MongoDB\Driver\Query; use MongoDB\Driver\ReadPreference; class Database { private $Database; private static $Instance; public function __construct() { $Manager = new Manager("mongodb://localhost:27017", array(), array()); $this->Database = $Manager; } public static function getInstance() { if (static::$Instance == null) { static::$Instance = new Database(); } return static::$Instance; } public function query($scheme, $query) { return $this->Database->executeQuery($scheme, $query, new ReadPreference(ReadPreference::RP_PRIMARY)); } } class App { public function run() { $db = Database::getInstance(); $query = new Query(array()); $cursor = $db->query("mydb.scheme_info", $query); foreach ($cursor as $document) { echo $document->value; } $query = new Query(array()); $cursor = $db->query("mydb.domain", $query); foreach ($cursor as $document) { echo $document->hostname; } } } $App = new App(); $App->run();
I'm also getting the issue if, for example, my App object is passed to another class (using new SomeClass($this)). I can't reproduce it in a separate case, however it does happen in my dev project, but I'd assume both issues are linked.
I know PHP7 support is low in the list, but it'd be awesome if you can just fix that single issue