Uploaded image for project: 'PHP Driver: Extension'
  1. PHP Driver: Extension
  2. PHPC-572

Ensure stream context does not go out of scope before socket init

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.1.7
    • Affects Version/s: 1.1.2
    • Component/s: None
    • None

      From mongodb/mongo-php-library#83:

      What I have found out, if I execute any method on Collection object within containers closure, this works no problem This is the original code (League Container service provider):

      $this->getContainer()->add('mongo-collection', function () {
          $context = stream_context_create(['ssl' => [
              'allow_self_signed' => true,
              'verify_peer'       => false,
              'verify_peer_name'  => false,
              'verify_expiry'     => false]
          ]);
      
          $manager = new Manager('mongodb://127.0.0.1:27017', ['ssl' => true], ['context' => $context]);
      
          $collection = new Collection($manager, 'dbName.collectionName');
      
          return $collection;
      });
      

      And if I add:

      $collection->count();
      

      right before the return, it works. If I comment it out, I get segfault. I have also tried other methods like findOne() and it again works.

            Assignee:
            jmikola@mongodb.com Jeremy Mikola
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            4 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: