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

Infinite loop iterating BSON object properties with foreach

    XMLWordPrintable

    Details

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

      Description

      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!!!!!
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jmikola Jeremy Mikola
              Reporter:
              jozsy123 Joseph K├Ânny?
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: