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

Persisting a document which references another document drops ID

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 1.0.0BETA2
    • Fix Version/s: None
    • Component/s: Persister
    • Labels:
      None
    • Environment:
      Debian, PHP 5.3.3-7 Suhosin fcgi

      Description

      I have two documents:

      @Document
      class A {
      /** @Id */
      public $id;
      /** @ReferenceOne */
      public $b;
      }

      @Document
      class B {
      /** @Id */
      public $id;
      }

      I have an already persisted instance of B, which A references,
      though while persisting A and examining the resulting collection the id of B is missing.

      {
      _id: '000123',
      b: {
      $db: 'mydb',
      $id: '',
      $ref: 'b'
      }
      }

      I debugged the code and found the error occurs in DocumentPersister.php at line 210 in the latest git version as of this posting.
      The code is:

      $inserts[$oid] = $data;

      where $data is:

      array(
      _id => MongoId(000123),
      b => array(
      $ref => 'b',
      $id => MongoID(123000),
      $db => 'mydb'
      )
      )

      and $inserts[$oid] becomes:

      array(
      $oid = array(
      _id => MongoId(000123),
      b => array(
      $ref => 'b',
      $id => MongoID(),
      $db => 'mydb'
      )
      )
      )

      This assignment makes the MongoID disappear somehow!!?

      Can't figure it out, could this be a problem with PHP itself?

        Activity

        Hide
        Robert Knutsson added a comment -

        The problem occurred since i was dumping the class before it was initialized, not realizing that proxy classes lazy loaded.

        Show
        Robert Knutsson added a comment - The problem occurred since i was dumping the class before it was initialized, not realizing that proxy classes lazy loaded.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: