Doctrine CouchDB ODM
  1. Doctrine CouchDB ODM
  2. CODM-31

UnitOfWork#doDetach does not remove a document from the identityMap - uses incorrect index

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Labels:
      None

      Description

      In UnitOfWork on line 656 the oid is used to index the identity map instead of the document id when detaching an object. This is probably due to an incomplete port from the ORM. The following change fixes the bug (I will make the change and request a merge):

      Currently:
      656: if (isset($this->identityMap[$oid])) {

      Should be:
      656: if (isset($this->identityMap[$this->documentIdentifiers[$oid]])) {

      Further suggestion

      Since the document id is guaranteed to be unique would it not be better to do away with the oid completely? It seems the following would be a relatively cheap substitute for the current getDocumentIdentifier() implementation (excluding the check that it is managed which is also currently done in this method):

      public function getDocumentIdentifier($document)
      {
      $class = $this->dm->getClassMetadata(get_class($document));
      return $class->getIdentifierValue($document);
      }

      Then all the arrays in the UnitOfWork can be indexed using the document id and the above method can be called to obtain that wherever spl_object_hash is currently used to obtain the $oid. (Of course, if running spl_object_hash is faster than retrieving the doc id as I suggest above then the current implementation is better.)

        Activity

        Marnus Weststrate created issue -
        Marnus Weststrate made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]

        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=CODM-31, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Marnus Weststrate
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: