Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-3241

object type fails to save serialized class to postgresql

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      Doctrine 2 fails to properly store data from serialize() into postgresql.
      This happens because the postgresql pdo driver truncates text on NULL bytes when escaping values. This leads to truncated serialized objects being inserted into the database.

      A ugly but working workaround for us is to call json_encode(serialize()) when saving to the database and unserialize(json_decode()) when reading the value back because json_encode properly serializes the NULL bytes of the serialize() output to readable text.

      This is pretty ugly though and it would help if doctrine would provide a minimal encoding/decoding function for postgresql that converts all NULL bytes to something else to not break the object type on postgresql.

        Issue Links

          Activity

          Hide
          Marco Pivetta added a comment -

          I'm fairly sure that we don't want to invent our own serialization format. Instead, base64_encode could work.

          Due to BC compat, we can't introduce it for 2.x, so it would have to be a completely new type.

          Show
          Marco Pivetta added a comment - I'm fairly sure that we don't want to invent our own serialization format. Instead, base64_encode could work. Due to BC compat, we can't introduce it for 2.x, so it would have to be a completely new type.
          Hide
          Reno Reckling added a comment -

          Agreed, we'll just go with base64_encode for now.
          Maybe someone should update the documentation that using the object type on postgresql is not working as well as that using binary strings containing a NULL byte in any varchar/text column on postgresql is not working either.

          Show
          Reno Reckling added a comment - Agreed, we'll just go with base64_encode for now. Maybe someone should update the documentation that using the object type on postgresql is not working as well as that using binary strings containing a NULL byte in any varchar/text column on postgresql is not working either.
          Hide
          Marco Pivetta added a comment -

          Reno Reckling just open a pull request against the doctrine/doctrine2 repository

          Show
          Marco Pivetta added a comment - Reno Reckling just open a pull request against the doctrine/doctrine2 repository
          Show
          Reno Reckling added a comment - Marco Pivetta Here you go: https://github.com/doctrine/dbal/pull/653 http://www.doctrine-project.org/jira/browse/DBAL-964 Thanks for the reply.
          Hide
          Doctrine Bot added a comment -

          A related Github Pull-Request [GH-653] was closed:
          https://github.com/doctrine/dbal/pull/653

          Show
          Doctrine Bot added a comment - A related Github Pull-Request [GH-653] was closed: https://github.com/doctrine/dbal/pull/653
          Hide
          Marco Pivetta added a comment -

          Merged DBAL-964, but the issue persists here.

          Show
          Marco Pivetta added a comment - Merged DBAL-964 , but the issue persists here.

            People

            • Assignee:
              Benjamin Eberlei
              Reporter:
              Reno Reckling
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: