Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Labels:
      None

      Activity

      Hide
      Marnus Weststrate added a comment -

      I obtained the latest build from git://github.com/doctrine/couchdb-odm.git so this is an active bug which I believe is related to this issue.

      The Doctrine\ODM\CouchDB\Mapping\Driver\AnnotationDriver produced the exception Class Test is not a valid document or mapped super class for even the most basic document with an Id and one Field. The exception was thrown on line 122 of the above class.

      The problem:
      In the code segment:
      108: $classAnnotations = $this->reader->getClassAnnotations($reflClass);
      109: if (isset($classAnnotations['Doctrine\ODM\CouchDB\Mapping\Document']))
      the getClassAnnotations method does not return an array of annotations indexed by annotation names, it uses numeric indexes. This causes the if-statements to always fail and thus the exception is thrown.

      A temporary workaround:
      108: $classAnnotations = $this->reader->getClassAnnotations($reflClass);
      Add: $classAnnotations = $classAnnotations[0];
      109: if ($classAnnotations instanceof \Doctrine\ODM\CouchDB\Mapping\Document) {
      110: $documentAnnot = $classAnnotations;
      Rather than checking for the proper index verify the class of the annotation object (Similar to the handling of $fieldAnnot following this code block). This approach assumes that the @Document annotation is the first Doctrine related annotation in the class doc block (which is fine, since it is the only one that should be used). Standard annotations such as @author can precede the @Document one since these are ignored by the getClassAnnotations method. The same changes should be applied to all the if statements up to line 120.

      Show
      Marnus Weststrate added a comment - I obtained the latest build from git://github.com/doctrine/couchdb-odm.git so this is an active bug which I believe is related to this issue. The Doctrine\ODM\CouchDB\Mapping\Driver\AnnotationDriver produced the exception Class Test is not a valid document or mapped super class for even the most basic document with an Id and one Field. The exception was thrown on line 122 of the above class. The problem: In the code segment: 108: $classAnnotations = $this->reader->getClassAnnotations($reflClass); 109: if (isset($classAnnotations ['Doctrine\ODM\CouchDB\Mapping\Document'] )) the getClassAnnotations method does not return an array of annotations indexed by annotation names, it uses numeric indexes. This causes the if-statements to always fail and thus the exception is thrown. A temporary workaround : 108: $classAnnotations = $this->reader->getClassAnnotations($reflClass); Add: $classAnnotations = $classAnnotations [0] ; 109: if ($classAnnotations instanceof \Doctrine\ODM\CouchDB\Mapping\Document) { 110: $documentAnnot = $classAnnotations; Rather than checking for the proper index verify the class of the annotation object (Similar to the handling of $fieldAnnot following this code block). This approach assumes that the @Document annotation is the first Doctrine related annotation in the class doc block (which is fine, since it is the only one that should be used). Standard annotations such as @author can precede the @Document one since these are ignored by the getClassAnnotations method. The same changes should be applied to all the if statements up to line 120.

        People

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

          Dates

          • Created:
            Updated: