mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #9637] Fix exception message in "missingFieldName" MappingException method #11765
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/doctrine/orm/pull/9637
State: closed
Merged: No
I encountered a legitimate
MappingExceptionwith XML mapping :Indeed I used
nameattribute by mistake for mymany-to-onerelationship. So I apply the suggested change :But then I still have the same error message. Comparing to the documentation, I find out that the real attribute to use is
field. Once I replacedfieldNamewith it, it works ! But it seemed to me that the exception message was misleading.I found out in
ClassMetadataInfo.phpthat indeed we look for afieldNamekey in the mapping data:1ffb9152f7/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php (L1777-L1781)Seemed that the mapping was modified when parsing the XML file. I found the culprit in
XmlDriver.php:1ffb9152f7/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php (L507-L509)The same transformation is performed for
one-to-oneandmany-to-manyassociations. As I suppose there's a reason to do it, I just changed in this PR the suggested correction inMappingExceptionby replacingfieldNamewithfieldin the exception message.I didn't found relevant to change the
missingFieldNamemethod to fit that change becausemissingFieldcould imply something else imho.