Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1244

[regression] Entities generator fails to update entities without any namespace, always append the generated definitions to the end of the class

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.1
    • Fix Version/s: 2.1.1
    • Component/s: Tools
    • Security Level: All
    • Labels:
      None
    • Environment:
      Zend_Framework 1.11, Doctrine 2.x, YAML mapping

      Description

      If Entities have no namespace set (e.g. custom AutoLoader) schema tool fails to find the original methods and properties and always append the definitions to the end of the file, which leads to duplications of class definitions.

      This is because in \Doctrine\ORM\Tools\EntitiesGenerator.php at line 441:

      441: $lastSeenClass = $lastSeenNamespace . '\\' . $token[1];

      $lastSeenClass is always prefixed with "\" when checking for existing definitions

      it could be fixed as:

      441: $lastSeenClass =  $lastSeenNamespace. ($lastSeenNamespace ? '\\' : '') . $token[1];

      I had an environment where the classes without any specified namespace are autoloaded from Entities directory, which makes generate-entities fail to work properly since Doctrine 2.0.4

        Activity

        Hide
        Benjamin Eberlei added a comment -

        Fixed

        Show
        Benjamin Eberlei added a comment - Fixed

          People

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

            Dates

            • Created:
              Updated:
              Resolved: