Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Hi,
Awesome module!... :)
D7: 7.14
Version: 7.x-1.0-beta5+6-dev
Error:
EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7539 of /home/server/.drupal/7/development/drupal-7.14/pressflow/demo/includes/common.inc).
I got this right after I saved the settings. I've seen this error from other modules and I've read Drupal is forcing a more strict coding standarded which: I believe should have been done along time ago, but is there a patch for this?
Here is the function calling this error:
function entity_extract_ids($entity_type, $entity) {
$info = entity_get_info($entity_type);
// Objects being created might not have id/vid yet.
$id = isset($entity->{$info['entity keys']['id']}) ? $entity->{$info['entity keys']['id']} : NULL;
$vid = ($info['entity keys']['revision'] && isset($entity->{$info['entity keys']['revision']})) ? $entity->{$info['entity keys']['revision']} : NULL;
if (!empty($info['entity keys']['bundle'])) {
// Explicitly fail for malformed entities missing the bundle property.
if (!isset($entity->{$info['entity keys']['bundle']}) || $entity->{$info['entity keys']['bundle']} === '') {
>>-------------------------------------> throw new EntityMalformedException(t('Missing bundle property on entity of type @entity_type.', array('@entity_type' => $entity_type))); <-------------------------------------------------<<
}
$bundle = $entity->{$info['entity keys']['bundle']};
}
else {
// The entity type provides no bundle key: assume a single bundle, named
// after the entity type.
$bundle = $entity_type;
}
return array($id, $vid, $bundle);
}
Thanks!
Comment | File | Size | Author |
---|---|---|---|
#39 | 1576664_39.patch | 553 bytes | Mile23 |
#37 | entityreference-entity-null-1576664-37.patch | 552 bytes | bendiy |
#14 | entityreference-entity-null-1576664-14.patch | 990 bytes | MegaChriz |
#7 | 1576664-entity-null-7.patch | 707 bytes | amitaibu |
#2 | Modules _ Enabled.pdf | 1.07 MB | Vc Developer |
Comments
Comment #1
amitaibuAre you sure the referenced node does have a non-deleted node-type?
Comment #2
Vc Developer CreditAttribution: Vc Developer commentedHi, thanks for the reply!
This is a fresh install to find out why I was getting this message when I was trying to do a preview. Because before is was working fine, but don't know if any of the other modules I added caused the problem. I've attached a PDF of what modules I have enabled thus far after the fresh install. Now I get the message every time I try to save or edit the field.
I will eliminate mod's from this point and see what happens.
P.S. I'm using the References Module now and its working perfectly, but would like to return back because I understand this will be the future for this type.
Comment #3
Vc Developer CreditAttribution: Vc Developer commentedHi,
I just finished doing a new D7.14 install and only enabled CTools and Entity API with the same results.... :(
Comment #4
abtm CreditAttribution: abtm commentedI am having the same problem. It works fine with 7.x-1.0-rc1. This problem occurred after I upgraded it to 7.x-1.x-dev. Any ideas on what's going wrong?
Comment #5
Offlein CreditAttribution: Offlein commentedSame thing! Fresh install, right after I added my first Entity Reference field. I have a very basic selection of modules enabled.
Also! My entity was a USER, not a NODE.
Comment #6
bojanz CreditAttribution: bojanz commentedThis was introduced by:
At the top of entityreference_field_widget_form() the $entity gets initialized to NULL because $element['#entity'] is missing, which gets passed to entity_extract_ids, which chokes.
EDIT: Okay, that was because the install wasn't on Drupal 7.14, and the latest Entityreference -dev requires Drupal 7.14, because that's when $element['#entity'] was introduced. So there needs to be a hook_requirements() / info file dependency for Drupal 7.14.
Comment #7
amitaibuThis happens also on 7.14, when adding a new field. Attached patch checks $entity exists before doing
entity_extract_ids()
Comment #8
abtm CreditAttribution: abtm commented1576664-entity-null-7.patch breaks my site.
Comment #9
amitaibuAbtm, I'll need more info...
Comment #10
owntheweb CreditAttribution: owntheweb commentedI seem to be having the same issue. My install is not fresh, but all my modules and Drupal core are up-to-date at 7.14. The problem started happening when trying to delete nodes after upgrading/updating everything from 7.12 to 7.14. Let me know what kind of specifics I can provide on this. :)
Comment #11
abtm CreditAttribution: abtm commentedAfter I applied the patch in #8 last time, my site went blank. Tried a few times the got the same result. Then I reported it. But today after I applied it once again it worked. The error msg doesn't come out any more. No clue....
Comment #12
MXTI've had the same error, but patch in #7 resolved it.
The error occurred when tried to edit an existing entity reference field.
Comment #13
Damien Tournoud CreditAttribution: Damien Tournoud commentedThis doesn't look correct. We do need the additional
/
even when the entity is not defined.Comment #14
MegaChriz CreditAttribution: MegaChriz commentedThe attached patch fixes the issue noted in #13. The additional
/
is added to the line above.Comment #15
checker CreditAttribution: checker commented#14 is working for me.
Comment #16
mikemadison CreditAttribution: mikemadison commentedThe patch does NOT seem to be working for me. I am still getting the error after applying it. I originally got the error using RC1, and I upgraded to Dev, then applied the patch. Anyone else confirm or deny if this fixed their problem?
Comment #17
mikemadison CreditAttribution: mikemadison commentedActually, in digging a bit more, it looks like other factors may play into this bug than just entity reference. I didn't have that module enabled at first and I was still getting this same error.
Comment #18
mikemadison CreditAttribution: mikemadison commentedSee http://drupal.org/node/1277376#comment-5925664 for another possible solution, if you are like me and are having this particular error even when you don't have modules enabled.
Comment #19
checker CreditAttribution: checker commentedI tested it with current dev
Comment #20
Anonymous (not verified) CreditAttribution: Anonymous commented#14 works for me, too (current dev)
Comment #21
Arrow#14 worked on the current dev!
Comment #22
klucid CreditAttribution: klucid commentedPatch #14 did not fix the problem. Actually, updating the the dev broke my site.
Fatal error below:
Edit: Confirming that it was the dev version of the module that broke the site. Undid patch, same error, reinstalled RC1 and it's back to normal.
Comment #23
klucid CreditAttribution: klucid commentedFor what it's worth:
For the people trying to delete user accounts, if you select "Delete the account and make its content belong to the Anonymous user," the deletion goes through successfully.
Hope this helps.
Comment #24
Anonymous (not verified) CreditAttribution: Anonymous commented@klucid: You'll need to update or patch OG. See #1571384: Update OgSelectionHandler to match parent EntityReference_SelectionHandler_Generic
Comment #25
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #26
GiorgosK#14 works great
Comment #27
Damien Tournoud CreditAttribution: Damien Tournoud commentedMerged into 7.x-1.x, thanks!
Comment #28
Preston McMurry CreditAttribution: Preston McMurry commentedI do not have entityreference module installed, yet still get the error on line 7539 of common.inc in Drupal 7.14. Further details here: http://drupal.org/node/1277376#comment-6095438
Perhaps entityreference is not the only module that requires this (or a similar) patch. What should I grep the codebase for to find other places to patch?
Comment #29
Anonymous (not verified) CreditAttribution: Anonymous commentedFor sure entityreference is not the only module. The error occurs when calling entity_extract_ids() without proper $entity. You need to find out who's breaking the entity. According to your posting in the other issue, you could follow field_attach_update() until you hit entity_extract_ids() or enable a call stack somehow. Just in case the entity you pass in is intact.
Comment #31
HongPong CreditAttribution: HongPong commentedThis may be a tangent but if you have malformed files entities - see #1446440: Unable to view me media management pages (EntityMalformedException: Missing bundle property...) for my one-off SQL fix for column type in the files_managed table.
Comment #32
lshao999 CreditAttribution: lshao999 commented#14 patch works for me. After the patch, a dozen error messages were displayed, revealing the real culprit (Read more control module). After disabling the module, everything is normal. (My project has updated to core 7.15)
Comment #33
Alan D. CreditAttribution: Alan D. commentedHi, just wondering why this was transferred to this queue?
What is the issue and how would I replicate it? The EntityMalformedException is an exception thrown when the entity is not loaded completely and then used in the entity system functions. (i.e. it is very generic)
Have you have a copy of the notices that this module was throwing?
Comment #34
clashar CreditAttribution: clashar commentedI have no "Read More Control" module, so it's not issue for this project.
Comment #35
Anonymous (not verified) CreditAttribution: Anonymous commentedWould you please stop adding new comments here and read back to #29.
The original issue was in the responsibility of Entity reference and it really is already solved.
Please understand: the same error message can result from any module calling entity_extract_ids().
If you're seeing the error again, go find out who causes it. If you can't, go find someone who can. But do not ever touch this issue.
Oh wow, this feels like talking to my little daughter. :)
Comment #36
DevElCuy CreditAttribution: DevElCuy commentedHint for the ones that still get this error.
I'm building a batch import script with migrate module. Got this error when inserting 0 to an entityrefence field, so what I did is to patch my source SQL query, making it translate 0 to NULL, so the field is processed as empty and not as having an invalid value.
Comment #37
bendiy CreditAttribution: bendiy commentedI'm still getting this error on some use cases. I think the root cause is that you're using '$instance['entity_type']' when you should use '$element['#entity_type']'.
The field options module does it like this:
http://drupalcode.org/project/drupal.git/blob/refs/heads/7.x:/modules/fi...
See attached patch.
Comment #38
Chris Matthews CreditAttribution: Chris Matthews commentedThe 5 year old patch in #37 to entityreference.module does not apply to the latest 7.x-1.x-dev and if still relevant needs a reroll.
Comment #39
Mile23Reroll of #37 against current dev.
Also applies to 7.x-1.5.
Also note: This didn't solve the problem for me. :-)
Comment #40
Mile23