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

Infinite loop iterating BSON object properties with foreach

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.4.0-RC1, 1.4.0
    • Affects Version/s: 1.4.0-beta1
    • Component/s: None
    • None
    • Environment:
      mongodb/mongo-php-driver(Pecl MongoDB PHP extension)
      yii2-mongodb extension

      We use an ArrayHelper class wich convert the documents from MongoDB to multi array in Yii2 PHP framework.
      The helper explare all elements of the objects and it works recursively.
      We stored the creation of datetime in UTCDateTime, so this is an object in our documents.
      The ArrayHelper want to go along the object array with foreach. When the foreach reach the UTCDateTime object then the cycle goes infinity loop. For something it can not go over to the next item.
      I tried with the following versions of the mongodb PHP extension: 1.3.x, 1.4.0-beta1.
      The latest version where the problem does not occur the 1.2.11 version.

      //For example:
      
      $document = $model::findOne(['user_id' => 12]);
      foreach($document->date_created as $item){
        var_dump($item);
        //Infinity loop!!!!!
      }
      

            Assignee:
            jmikola@mongodb.com Jeremy Mikola
            Reporter:
            jozsy123 Joseph Könny?
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: