[CODM-28] Adjust to new Annotation Reader Created: 25/Jun/11  Updated: 10/Aug/11

Status: Open
Project: Doctrine CouchDB ODM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None

Comment by Marnus Weststrate [ 10/Aug/11 ]

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.

Generated at Tue Dec 01 13:25:25 EST 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.