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

Do not allow BSON arrays to be hydrated as PHP classes

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

      When php_phongo_bson_visit_document() and php_phongo_bson_visit_array() iterate on the keys within objects and arrays, respectively, the class name picked up by php_phongo_bson_visit_binary() is used for hydration and the unserialize method (i.e. BSON_UNSERIALIZE_FUNC_NAME) is invoked directly. From what I can tell, this code doesn't appear to check if the class itself implements the required interface.

      It also means that BSON arrays might get hydrated as classes iff they contain an appropriate binary data element. Unlike objects, I don't think we should rely on arrays containing elements, given that update operators are prone to removing elements from an array (see: $push with $slice). Also, this would mean that size checks done on the array during queries or in other drivers would differ from the size of the hydrated array in the PHP driver.

      If the user would like a BSON array to be hydrated as a PHP class, that is best done in the parent document classe that contains the array/collection field.

            Assignee:
            bjori Hannes Magnusson
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: