Skip to content

Loading…

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

Closed
doctrinebot opened this Issue · 2 comments

2 participants

@doctrinebot

Jira issue originally created by user mjh_ca:

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.

@doctrinebot

Comment created by @beberlei:

Fixed both issues, thanks for reporting.

@doctrinebot

Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.0-BETA2 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.