Uploaded image for project: 'PHP Driver: Library'
  1. PHP Driver: Library
  2. PHPLIB-494

Consider using array_key_exists for stricter validation

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.5.2
    • Affects Version/s: 1.5.1
    • Component/s: None
    • Labels:
      None

      In doctrine/mongodb-odm#2087, a user reported that GridFS file uploads hang when not explicitly specifying a chunk size in the ODM mapping. This was caused by the MongoDB ODM passing null for the chunkSizeBytes option to openUploadStream, which passes it on to MongoDB\GridFS\WritableStream.

      The constructor checks whether chunkSizeBytes is an integer value > 0, but these checks only happen if isset returns true. This is problematic, since isset will return false when an array item has a null value. In this case, the checks were bypassed, but the value used nonetheless, causing an endless loop when trying to upload a file.

      We should consider using array_key_exists, at least for some options to ensure that null values can't cause any adverse behaviour.

            Assignee:
            andreas.braun@mongodb.com Andreas Braun
            Reporter:
            andreas.braun@mongodb.com Andreas Braun
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: