Doctrine MongoDB ODM
  1. Doctrine MongoDB ODM
  2. MODM-61

GridFs file is stored incorrectly after two flushes

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0.0BETA2
    • Component/s: Persister
    • Labels:
      None

      Description

      GridFs file is stored incorrectly after two flushes.

      Consider an example:

      /** @Document(db="tests", collection="fs") */
      class File
      {
          /** @Id */
          protected $id;
      
          /** @File */
          protected $file;
      
          function  __construct($source) {$this->file = $source;}
      }
      
      $file = new File(__DIR__ . '/test.txt');
      
      $dm->persist($file);
      $dm->flush();
      $dm->flush();
      

      After second flush, doctrine will also store "file" property as if it was a regular object. Expecting:

      {
        "_id": "4c777fc00f9d505407020000",
        "filename": "/test.txt",
        "uploadDate": {
          "sec": 1282899904,
          "usec": 0
        },
        "length": 10,
        "chunkSize": 262144,
        "md5": "76ce9f441de2ed5de337d391ad4516b7"
      }
      

      Actual result:

      {
        "_id": "4c777f780f9d508416020000",
        "chunkSize": 262144,
        "file": {
          "file": {
            "_id": {},
            "filename": "/test.txt",
            "uploadDate": {
              "sec": 1282899832,
              "usec": 0
            },
            "length": 10,
            "chunkSize": 262144,
            "md5": "76ce9f441de2ed5de337d391ad4516b7"
          },
          "": {
            "w": 1,
            "wtimeout": 10000,
            "chunks": {
              "w": 1,
              "wtimeout": 10000
            },
            "": "fs.chunks"
          }
        },
        "filename": "/test.txt",
        "length": 10,
        "md5": "76ce9f441de2ed5de337d391ad4516b7",
        "uploadDate": {
          "sec": 1282899832,
          "usec": 0
        }
      }
      

      P.S. Unfortunately cannot use PHPUnit 3.5 right now to provide unit test.

        Activity

        Show
        Jonathan H. Wage added a comment - Fixed by http://github.com/doctrine/mongodb-odm/commit/e8945bc53b59e8c8b8c0b13df0b73a8774c7111b

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Vladimir Razuvaev
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: