Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-592

'undefined index' errors from CLI orm:validate-schema when inversedBy field does not exist on inverse side

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-BETA2
    • Fix Version/s: 2.0-BETA2
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      Line 126 of Doctrine/ORM/Tools/SchemaValidator.php runs the following test:

          } else  if ($targetMetadata->associationMappings[$assoc->inversedBy]->mappedBy != $fieldName) {
      

      If the mapping is incomplete (i.e. inversedBy field does not exist at all on the inverse side of the relationship), running orm:validate-schema throws errors like:

      Notice: Undefined index: foo in \lib\Doctrine\ORM\Tools\SchemaValidator.php on line 126
      
      Notice: Trying to get property of non-object in \lib\Doctrine\ORM\Tools\SchemaValidator.php on line 126
      

      (where 'foo' is the field that was defined on the the owning side with the inversedBy attribute but does not exist on the inverse side)

      Since the objective is to detect mapping errors, there should probably be extra checks for this.

      A similar issue also happens on line 98 if the mappedBy field defined on the inverse side does not exist on the owning side.

      My quick assessment is that if the earlier hasField() / hasAssociation() tests have failed then some of the subsequent tests should be skipped since they do not apply.

        Activity

        Hide
        Benjamin Eberlei added a comment -

        Fixed both issues, thanks for reporting.

        Show
        Benjamin Eberlei added a comment - Fixed both issues, thanks for reporting.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: