Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1354

ClassName proxy classes has includes '\' in front of namespace while other don't

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.7
    • Fix Version/s: 2.1.2
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      All?

      Description

      The classname given to the EntityPersister by the ProxyFactory includes a backslash '\' in front of the namespace while normal classes and the proxy itself don't have this. This issue causes it impossible to persist proxyclasses, because of the string comparison in UnitOfWork::executeUpdates in the statement [ get_parent_class($entity) == $className ] this will do 'some\namespace\someclass' == '\some\namespace\someclass'

      Aftter some debugging work it seems the '\' is trimmed of when getting the ClassMetadata while this isn't done when a the proxyfactory creates the proxy. So it is probably fixed by placing:

      $className = ltrim($className, '\');

      at the start of ProxyFactory::getProxy where '\' is actually a double backslash but that cannot be posted here

        Activity

        Hide
        Guilherme Blanco added a comment -

        That was not the issue, but it was a good starting point.
        The actual problem was during mapping that targetEntity never ltrim'ed the entity name referred there.
        Internally, Hydrator and UnitOfWork consume the ProxyFactory directly, so it lead to a wrong hashmap key for persisters.

        By fixing the targetEntity value, everything is fixed. =)

        https://github.com/doctrine/doctrine2/commit/ecc556f6872c0d44fff5678dc38e068422962aa0

        Show
        Guilherme Blanco added a comment - That was not the issue, but it was a good starting point. The actual problem was during mapping that targetEntity never ltrim'ed the entity name referred there. Internally, Hydrator and UnitOfWork consume the ProxyFactory directly, so it lead to a wrong hashmap key for persisters. By fixing the targetEntity value, everything is fixed. =) https://github.com/doctrine/doctrine2/commit/ecc556f6872c0d44fff5678dc38e068422962aa0
        Hide
        Benjamin Eberlei added a comment -

        merged into 2.1.x

        Show
        Benjamin Eberlei added a comment - merged into 2.1.x

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            Bas
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: