mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-31: ClassMetadata discriminatorColumn['name'] should always be set when discriminatorColumn is not null #38
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Oct 3, 2009).
Originally assigned to: @guilhermeblanco on GitHub.
Jira issue originally created by user itoijala:
When creating an entity, StandardEntityPersister checks if the discriminatorColumn is null. If not it checks if discriminatorColumn['name'] is $column. Sometimes (not sure when), discriminatorColumn['name'] is not set. warning is then emitted:
Notice: Undefined index: name in D:\Projects\NewStein\library\Doctrine\ORM\Persisters\StandardEntityPersister.php on line 504
ClassMetadata should ensure that discriminatorColumn['name'] is always set.
Fix:
OLD (ClassMetadata.php, line 1567):
NEW:
@doctrinebot commented on GitHub (Oct 3, 2009):
Comment created by @guilhermeblanco:
In changeset http://trac.doctrine-project.org/changeset/6419 this issue is fixed.
Thanks for report and patch!
@doctrinebot commented on GitHub (Oct 3, 2009):
Comment created by @guilhermeblanco:
We didn't feel comfortable with this patch. I've spoken with Roman about it too.
I won't revert it, but I'd like to ask you more information, like your schema and piece of code that you got this error. I'll then wrap it in a test case for more investigation.
Reopened the issue, since solution is not optimal.
@doctrinebot commented on GitHub (Oct 3, 2009):
Comment created by itoijala:
OK.
First the schema (I suppose you mean the entity classes):
Blameable.php
User.php
Then the controller action (I'm using the Zend Framework)
The view code:
This outputs the __toString() and emits 3 of the above notices. By echoing the column in StandardEntityPersister I found out that the notices are caused by creator_id, updater_id and deleter_id (these are the only associations).
The code in StandardEntityPersister expects the discriminatorColumn to be either null or have a name key.
StandardEntityPersister.php around line 504
Either discriminatorolumn has to have a name key if it is not null (the discriminatorColumn only had an empty fieldName key when print_r'd), or the above code has to be changed.
@doctrinebot commented on GitHub (Oct 3, 2009):
Comment created by romanb:
The question here is why discriminatorColumn is not null. Thats what I'm looking into currently. Of course we can also add a check in setDiscriminatorColumn additionally and throw an exception if name is not set since name is mandatory, only fieldName is optional and defaults to the name if not set. Thats why the current patch doesnt make much sense.
You are not using any discriminator columns actually, are you? (@DiscriminatorColumn(...)) ?
@doctrinebot commented on GitHub (Oct 3, 2009):
Comment created by romanb:
Found the issue. The main reason was that setDiscriminatorColumn was not checking for null, thus classes that did not even have a discriminator column in a mapped hierarchy got an array set with just fieldName set.
Alternatively we could have added the null check to clients that call setDiscriminatorColumn, like ClassMetadataFactory, but I figured it would be safer to do it in the method.
@doctrinebot commented on GitHub (Oct 3, 2009):
Issue was closed with resolution "Fixed"