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

Consider using array_key_exists for stricter validation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 1.5.1
    • Fix Version/s: 1.5.2
    • Labels:
      None

      Description

      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.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: