Doctrine 1
  1. Doctrine 1
  2. DC-132

LOB mode not used for BLOB fields that are specified as a file handle

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.0-ALPHA2
    • Fix Version/s: 1.2.0-BETA1
    • Component/s: Connection
    • Labels:
      None

      Description

      PDO provides us with the (highly desirable) possibility of providing the contents for a blob file through a filehandle resource, so the data can be read directly from a file or another stream source. When retrieving blob data from the database, I already get such file handle back. However, when creating of updating a record with a blob field using a filehandle, this fails. It fails because of two issues:

      • Doctrine_Validator::isValidType() rejects the resource handle, because blob fields are only checked using is_string().
      • $sth->execute($params) is used for executing a query after preparing it. The $params are provided straight away to the statement handle, without differentiating between field types by means of explicit bindings. An explicit binding with Doctrine::PARAM_PDO would be needed to allow for field data upload using a filehandle.

      I have already been going over the code and I could not find a very good spot for handling this. What functionally should happen is that:

      • a blob field
      • for which a stream resource is set
      • should not be rejected as a valid blob type field and
      • should be bound as a param to the prepared insert/update query
      • using the data type Doctrine::PARAM_LOB

      In the attached patch, I have updated the code in a way that makes this feature work. What I did feels like a hack, but I couldn't find a good way to implement this cleanly. The type of field that we are handling (blob or not?), the data that we are handling (resource or not?) and the spot where we can use bindParam() are not really tightly interconnected (or maybe they are and I overlooked it).

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Maurice Makaay
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: