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

Unexpected: MappedSuperclass private property without annotation becomes persisted

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0.0ALPHA1
    • Fix Version/s: 1.0.0ALPHA1
    • Component/s: None
    • Labels:
      None
    • Environment:
      OS X, latest ODM checkout

      Description

      /** @MappedSuperclass */
      class Model {
      
          private $errors = array();
      
          protected function getErrors() {
              return $this->errors;
          }
      }
      
      /**
       * @Document(db="mydb", collection="data")
       */
      class Data extends Model {
          /**
           * @Id
           */
          public $id;
      
          /**
           * @String
           */
          public $name;
      }
      

      Did not expect, that $errors goes into mongo.

        Activity

        Florian Kubis created issue -
        Jonathan H. Wage made changes -
        Field Original Value New Value
        Description /** @MappedSuperclass */
        class Model {

            private $errors = array();

            protected function getErrors() {
                return $this->errors;
            }
        }

        /**
         * @Document(db="mydb", collection="data")
         */
        class Data extends Model {
            /**
             * @Id
             */
            public $id;

            /**
             * @String
             */
            public $name;
        }

        Did not expect, that $errors goes into mongo.
        {code}
        /** @MappedSuperclass */
        class Model {

            private $errors = array();

            protected function getErrors() {
                return $this->errors;
            }
        }

        /**
         * @Document(db="mydb", collection="data")
         */
        class Data extends Model {
            /**
             * @Id
             */
            public $id;

            /**
             * @String
             */
            public $name;
        }
        {code}

        Did not expect, that $errors goes into mongo.
        Hide
        Jonathan H. Wage added a comment -

        This is expected behavior. It was changed so that all properties are persisted unless specified otherwise. Map the property is @Transient and it will be ignored by Doctrine:

        class MyDocument
        {
            // ...
        
            /** @Transient */
            private $errors = array();
        }
        
        Show
        Jonathan H. Wage added a comment - This is expected behavior. It was changed so that all properties are persisted unless specified otherwise. Map the property is @Transient and it will be ignored by Doctrine: class MyDocument { // ... /** @Transient */ private $errors = array(); }
        Jonathan H. Wage made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Florian Kubis added a comment -

        Thanks, this works.
        Just to complete this issue, for now documentation of @Transient is missing in the reference.
        http://www.doctrine-project.org/projects/mongodb_odm/1.0/docs/reference/annotations-reference/en

        Show
        Florian Kubis added a comment - Thanks, this works. Just to complete this issue, for now documentation of @Transient is missing in the reference. http://www.doctrine-project.org/projects/mongodb_odm/1.0/docs/reference/annotations-reference/en
        Hide
        Jonathan H. Wage added a comment -

        Thanks. I have updated the documentation with the new @Transient annotation.

        Show
        Jonathan H. Wage added a comment - Thanks. I have updated the documentation with the new @Transient annotation.
        Jonathan H. Wage made changes -
        Affects Version/s 1.0.0ALPHA1 [ 10064 ]
        Fix Version/s 1.0.0ALPHA1 [ 10064 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=MODM-9, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

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

            Dates

            • Created:
              Updated:
              Resolved: