DDC-580: loadMappingFile in XmlDriver #712

Closed
opened 2026-01-22 12:47:40 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (May 9, 2010).

Jira issue originally created by user needle:

There is just a minor bug on XmlDriver.

The actual code is :

protected function _loadMappingFile($file)
    {
        $result = array();
        $xmlElement = simplexml*load*file($file);

        if (isset($xmlElement->entity)) {
            foreach ($xmlElement->entity as $entityElement) {
                $entityName = (string)$entityElement['name'];
                $result[$entityName] = $entityElement;
            }
        } else if (isset($xmlElement->{'mapped-superclass'})) {
            foreach ($xmlElement->{'mapped-superclass'} as $mapperSuperClass) {
                $className = (string)$mappedSuperClass['name'];
                $result[$className] = $mappedSuperClass;
            }
        }

        return $result;
    }

The error is on the foreach section. The code should be :

protected function _loadMappingFile($file)
    {
        $result = array();
        $xmlElement = simplexml*load*file($file);

        if (isset($xmlElement->entity)) {
            foreach ($xmlElement->entity as $entityElement) {
                $entityName = (string)$entityElement['name'];
                $result[$entityName] = $entityElement;
            }
        } else if (isset($xmlElement->{'mapped-superclass'})) {
            foreach ($xmlElement->{'mapped-superclass'} as $mappedSuperClass) {
                $className = (string)$mappedSuperClass['name'];
                $result[$className] = $mappedSuperClass;
            }
        }

        return $result;
    }
Originally created by @doctrinebot on GitHub (May 9, 2010). Jira issue originally created by user needle: There is just a minor bug on XmlDriver. The actual code is : ``` php protected function _loadMappingFile($file) { $result = array(); $xmlElement = simplexml*load*file($file); if (isset($xmlElement->entity)) { foreach ($xmlElement->entity as $entityElement) { $entityName = (string)$entityElement['name']; $result[$entityName] = $entityElement; } } else if (isset($xmlElement->{'mapped-superclass'})) { foreach ($xmlElement->{'mapped-superclass'} as $mapperSuperClass) { $className = (string)$mappedSuperClass['name']; $result[$className] = $mappedSuperClass; } } return $result; } ``` The error is on the foreach section. The code should be : ``` php protected function _loadMappingFile($file) { $result = array(); $xmlElement = simplexml*load*file($file); if (isset($xmlElement->entity)) { foreach ($xmlElement->entity as $entityElement) { $entityName = (string)$entityElement['name']; $result[$entityName] = $entityElement; } } else if (isset($xmlElement->{'mapped-superclass'})) { foreach ($xmlElement->{'mapped-superclass'} as $mappedSuperClass) { $className = (string)$mappedSuperClass['name']; $result[$className] = $mappedSuperClass; } } return $result; } ```
admin added the Bug label 2026-01-22 12:47:40 +01:00
admin closed this issue 2026-01-22 12:47:41 +01:00
Author
Owner

@doctrinebot commented on GitHub (May 10, 2010):

Comment created by shurakai:

Fixed in http://github.com/Shurakai/doctrine2 and should be fixed in trunk soon.

@doctrinebot commented on GitHub (May 10, 2010): Comment created by shurakai: Fixed in http://github.com/Shurakai/doctrine2 and should be fixed in trunk soon.
Author
Owner

@doctrinebot commented on GitHub (May 10, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (May 10, 2010): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#712