upon restore, we get this error:

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /autosave/restore/some-node-form/1326387480
StatusText: Service unavailable (with message)
ResponseText: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7409 of .../includes/common.inc).

Modules that may be relevant:

Autosave 7.x-2.x-dev
Entity 7.x-1.0-rc1 and API 7.x-1.x-dev 2012-Jan-10 (tried both)
Field collection 7.x-1.0-beta2 and 7.x-1.x-dev 2012-Jan-11 (tried both)

The node in question is made up of a number of fields and field collections. The fields vary in type and include file, image and text.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Crell’s picture

Project: Autosave » Entity API
Version: 7.x-2.x-dev » 7.x-1.x-dev
Component: Code » Code - misc

I don't see how this is autosave related. I think autosave is just triggering an existing but in Entity, but I really couldn't say. Refiling.

fago’s picture

Project: Entity API » Autosave
Component: Code - misc » Code
Status: Active » Postponed (maintainer needs more info)

The error stems from core, not from the entity api module. Maybe this is a problem triggered by the autosave-field-collection combination though? Best check whether the problem appears without using field-collection too.

cjgriffin’s picture

I can confirm that the problem appears without using field-collection too. Without Entity or Field collection installed, I get the following on restore attempt (the only difference it seems from the original post is that the StatusText is Internal Server Error instead of Service unavailable):

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /autosave/restore/some-node-form/1327260091
StatusText: Internal Server Error
ResponseText: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7409 of .../includes/common.inc).

I'm using WYSIWYG and TinyMCE.

oobie11’s picture

This is what I'm getting:

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /autosave/restore/my-node-form/1327998249
StatusText: error
ResponseText: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7409 of .../includes/common.inc).

Crell’s picture

I still cannot reproduce. Can you post a backtrace from that point? (Find the line that throws the exception, and right before it call debug_backtrace() and dump the array it returns somewhere, then post it here.)

sillygwailo’s picture

I got http://pastebin.com/5rt8ycc3 when putting debug_backtrace() before line 7389 in common.inc (Drupal 7.8). Autosave + Wysiwyg + TinyMCE on the Basic page content type with no special fields added.

sillygwailo’s picture

http://pastebin.com/uTiqcidc is a backtrace for Drupal 7.9.

sillygwailo’s picture

http://pastebin.com/PzmH3FyL updated for plain vanilla Drupal 7.12 (fresh install, nothing else enabled but the latest dev release of Autosave). Error is at line 7501 of common.inc this time.

CB’s picture

It appears, from a very brief investigation, that the page arguments are simply a sting of the node type, when the form in question is a node/add form.

So, for example, if you try to create a new node of type 'article' - autosave.module will send the string 'article' in the form_state args and drupal will treat that string as an object, of which it has no type or bundle association.

    $form_state['input'] = unserialize($record->serialized);
    $form_state['build_info']['args'] = $menu_item['page_arguments']; // <-- This is a string, not an object.

At the bottom of drupal_retrieve_form in form.inc ...

  $form = call_user_func_array(isset($callback) ? $callback : $form_id, $args); // <-- Args is the string 'article' from above

And, in node.pages.inc, you can see that it is expecting a node, not a string.

function node_form($form, &$form_state, $node) {
  global $user;

  // During initial form build, add the node entity to the form state for use
  // during form building and processing. During a rebuild, use what is in the
  // form state.
  if (!isset($form_state['node'])) {
    if (!isset($node->title)) {
      $node->title = NULL;
    }
    node_object_prepare($node);
    $form_state['node'] = $node;
  }
  else {
    $node = $form_state['node'];
  }

I'm happy to look further and try to create a patch, I just dont have time at the moment.

Hopefully this helps.

Crell’s picture

Project: Autosave » Entity API
Component: Code » Code - misc
Status: Postponed (maintainer needs more info) » Active

I just got this exact same error on another site I'm working on that does not have autosave on it at all. The bug is with Entity API. Autosave is just doing something to trigger it (not sure what), as is whatever it is my site is doing.

In the case of my site, I have a series of node_save() calls (not even entity API related) in an install hook of a module, which is crashing when I try to install it as part of a profile.

Refiling.

sillygwailo’s picture

Project: Entity API » Autosave
Version: 7.x-1.x-dev » 7.x-2.x-dev
Component: Code - misc » Code

I'm not convinced it's the Entity API module, since I get it on a brand new site, Standard install profile, only Autosave enabled, without Entity API installed.

(Updating the branch since the original report was for 7.x-2.x.)

Some more info:

As the #1 user, if I do the following:

  1. visit node/add/page
  2. type in some text
  3. go to a different page on the site
  4. return to node/add/page
  5. click on "Restore"

I get the error originally-reported in a JavaScript popup.

If I visit autosave/restore/page-node-form/1331671331 (taken from the error message I got) directly in the browser, I get the following:

Error

The website encountered an unexpected error. Please try again later.
Error message
Warning: Attempt to assign property of non-object in node_form() (line 91 of path/to/drupal/modules/node/node.pages.inc).
Notice: Trying to get property of non-object in node_object_prepare() (line 939 of path/to/drupal/modules/node/node.module).
Warning: Attempt to assign property of non-object in node_object_prepare() (line 945 of path/to/drupal/modules/node/node.module).
Warning: Attempt to assign property of non-object in node_object_prepare() (line 945 of path/to/drupal/modules/node/node.module).
Warning: Attempt to assign property of non-object in node_object_prepare() (line 945 of path/to/drupal/modules/node/node.module).
Warning: Attempt to assign property of non-object in node_object_prepare() (line 949 of path/to/drupal/modules/node/node.module).
Warning: Attempt to assign property of non-object in node_object_prepare() (line 950 of path/to/drupal/modules/node/node.module).
Warning: Attempt to assign property of non-object in node_object_prepare() (line 958 of path/to/drupal/modules/node/node.module).
Notice: Trying to get property of non-object in comment_node_prepare() (line 1281 of path/to/drupal/modules/comment/comment.module).
Warning: Attempt to assign property of non-object in comment_node_prepare() (line 1281 of path/to/drupal/modules/comment/comment.module).
Notice: Trying to get property of non-object in menu_node_prepare() (line 569 of path/to/drupal/modules/menu/menu.module).
Warning: Attempt to assign property of non-object in menu_node_prepare() (line 593 of path/to/drupal/modules/menu/menu.module).
Notice: Trying to get property of non-object in menu_node_prepare() (line 609 of path/to/drupal/modules/menu/menu.module).
Warning: Attempt to modify property of non-object in menu_node_prepare() (line 609 of path/to/drupal/modules/menu/menu.module).
Notice: Trying to get property of non-object in node_content_form() (line 3571 of path/to/drupal/modules/node/node.module).
Notice: Trying to get property of non-object in node_form() (line 160 of path/to/drupal/modules/node/node.pages.inc).
Notice: Trying to get property of non-object in node_form() (line 169 of path/to/drupal/modules/node/node.pages.inc).
Notice: Trying to get property of non-object in node_form() (line 174 of path/to/drupal/modules/node/node.pages.inc).
Notice: Trying to get property of non-object in node_form() (line 180 of path/to/drupal/modules/node/node.pages.inc).
Notice: Trying to get property of non-object in node_form() (line 230 of path/to/drupal/modules/node/node.pages.inc).
Warning: date_timezone_set() expects parameter 1 to be DateTime, boolean given in format_date() (line 1937 of path/to/drupal/includes/common.inc).
Warning: date_format() expects parameter 1 to be DateTime, boolean given in format_date() (line 1947 of path/to/drupal/includes/common.inc).
Notice: Trying to get property of non-object in node_form() (line 230 of path/to/drupal/modules/node/node.pages.inc).
Warning: date_timezone_set() expects parameter 1 to be DateTime, boolean given in format_date() (line 1937 of path/to/drupal/includes/common.inc).
Warning: date_format() expects parameter 1 to be DateTime, boolean given in format_date() (line 1947 of path/to/drupal/includes/common.inc).
Notice: Trying to get property of non-object in node_form() (line 253 of path/to/drupal/modules/node/node.pages.inc).
Notice: Trying to get property of non-object in node_form() (line 258 of path/to/drupal/modules/node/node.pages.inc).
Notice: Trying to get property of non-object in node_form() (line 263 of path/to/drupal/modules/node/node.pages.inc).
Notice: Trying to get property of non-object in node_form() (line 270 of path/to/drupal/modules/node/node.pages.inc).
Notice: Trying to get property of non-object in node_form() (line 276 of path/to/drupal/modules/node/node.pages.inc).
Notice: Trying to get property of non-object in node_form() (line 297 of path/to/drupal/modules/node/node.pages.inc).
Notice: Trying to get property of non-object in node_form() (line 302 of path/to/drupal/modules/node/node.pages.inc).
EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7501 of path/to/drupal/includes/common.inc).
geek.de.nz’s picture

I think I have a fix for this. Will let you know here when I have perfected it.

geek.de.nz’s picture

FileSize
859 bytes

It's not beautiful I admit, but fixes this problem for me. I would like to be able to commit to this project. Can you make me a co-maintainer, please?

I would like to add some features and make this module better for our client but also for the Open Source world.

Thanks,
Tim

sillygwailo’s picture

Status: Active » Needs review
Crell’s picture

Status: Needs review » Needs work

I do not understand what that code is doing or why. It needs a better explanation in code comments at minimum.

Also, you should not put your name or random extra braces around code blocks. The patch file indicates well enough what you are changing.

geek.de.nz’s picture

FileSize
1.27 KB

Sorry, it is a bit confusing but it hopefully makes sense now. It fixes the bug in my fresh Drupal 7.12 installation with no other modules enabled except for the standard set.

I would be very keen to become a co-maintainer at this stage because there are a few things I would like to do with this module for our web application/cms configuration, for example make it work with the CKEditor or better with the whole WYSIWYG module.

geek.de.nz’s picture

No one has applied my patch to the trunk and because I need to get this working asap, I made my own fork at

https://github.com/geekdenz/drupal-autosave

If you run into this problem, maybe you should try my fork.

Apologies to the maintainers, but you haven't reacted on/accepted my patch. I guess you are busy with lots of things...

Crell’s picture

Patience, grasshopper. And please do not abuse the tag field.

The latest patch those still doesn't say what it's doing or why. The comments document what each line is doing, but that is useless. It is also incorrect format. (We almost never use end-of-line comments.)

What the code does not make clear is why we need to mess around with the menu field in order to avoid an exception thrown elsewhere. Looking at that, I have no idea why it's even relevant (especially since I cannot replicate the error in the first place) so I canot commit code the purpose of which I do not understand.

geek.de.nz’s picture

Category: bug » support
Priority: Normal » Major
Status: Needs work » Needs review
FileSize
981 bytes

Sorry about the tags and the impatience, I hadn't read the guidelines properly.

Mh, you say you cannot reproduce it. Are you sure, you tried it with the 7.12 version of Drupal and the 7.x-2.x branch?

Because I can reproduce it with that in even the simplest possible case. I installed 7.12 with all the standard settings, turned on the module and get an exception every time I click the restore link, after of course making the necessary configuration changes to enable the module.

You do not understand the code? Given you seem to be quite a celebrity at Drupal I am a bit surprised by that.

How about this revised patch? With an even easier comment (hopefully).

Feel free to write it better, but please bear with me. I'm only trying to improve a great open source project.

I would feel honoured to become a maintainer. I think it would benefit Drupal and open source in general as well. What if something happens to you like it did to one of my colleagues last week: Poor Robbie. The bus factor as I'm sure you know it's called.

geek.de.nz’s picture

Assigned: Unassigned » geek.de.nz
FileSize
1.61 KB

OK, just to prove my patience and will to persevere, here another patch with the correct coding standard, at least as far as the coder review module can tell. Also, replaced a db_query call to db_query_range which included a LIMIT clause. Just to make it more portable.

There are still bugs with this module in this branch, but I'm slowly fixing them.

Regards,
Tim

sillygwailo’s picture

Category: support » bug
jyee’s picture

Assigned: geek.de.nz » Unassigned

@geek.de.nz you shouldn't assign issues to yourself (or anyone else), unless you are a maintainer/co-maintainer of the project.

netw3rker’s picture

@geek.de.nz here are a few notes for you:

1) the line numbers of the patch are off by a bit. It looks like you rolled this patch against 7.x-2.0 and not 7.x-2.x-dev. you really should create the patch off of the dev branch.
2) I'm pretty the shortcut you used and commented out in the code here is fine:

+    //$node = (object) array('type'=>$type);
+    $node = new stdClass();
+    $node->type = $type;
+    node_object_prepare($node);

3) the modification here isn't actually a modification (i believe this is called cruft. patches shouldn't contain cruft):

-      ':type' => str_replace("-", "_", $path_args[2]))
-    )->fetchField();
+      ':type' => str_replace("-", "_", $path_args[2])))->fetchField();

Beyond that, everything looks ok to me. The patch does apply cleanly to 2.x-dev and appears to work. the only issue I see is that once I click "restore" the autosave message that comes up says:

This form was autosaved on 0,0Ignore - Restore

I'm not sure if it does that on sites that work correctly, so I'll assume that this is another issue & say that as long as the changes above get applied, its RTBC by me at least :)

Sill’s picture

I too get this Malformed Exception error on restore. Here is the full code.

"An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /autosave/restore/page-node-form/1340142499/tbol9M319XUqLUURD_xfR6i6FgFnQpeJ0hrKTxwf8uY
StatusText: error
ResponseText: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7539 of /mnt/www/html/daniel5dev/docroot/includes/common.inc)."

I haven't applied the patch from #20 (geek.de.nz) as it isn't in full patch mode yet.

GHaddon’s picture

After applying the patch from #20 to 7.x-2.x-dev version the problem seems to be solved. Cheers.

willmoy’s picture

Same as GHaddon. Problem exists on -2.0, the patch fixes it. Can post my .make file if that's helpful.

Crell’s picture

I believe you guys, I just don't understand WHY it works. That's the part I still don't get. I want to makes sure that "why" is adequately captured in the comments so that it doesn't confuse other people later.

micheas’s picture

I am pretty sure the why is that the form does not submit the bundle type as it cannot be changed, but bundle type is a required attribute of the node object being saved.

Getting the existing node, and then making the changes means that all the unchangeable attributes of the node object are submitted.

I would go with the patch in #20 as it catches all other immutable attributes (if they exist) of the node that have to be submitted with node_save() but are not returned with the form.

quicksketch’s picture

Status: Needs review » Needs work

The documentation for node_add() makes this pretty clear: http://api.drupal.org/api/drupal/modules%21node%21node.pages.inc/functio...

Essentially the node_form() function *must* take a full $node object, not just the content type as a string. However the current patch only seems to *fix* the node/add/x form, but it *breaks* the editing of nodes at node/x/edit. This is because it attempts to convert the *already converted* menu item (a node) into a new node, which is unnecessary. I'm working on correcting this remaining problem so that the form properly saves both on addition and editing.

quicksketch’s picture

Status: Needs work » Fixed
FileSize
1.73 KB

I've committed this patch based on @geek.de.nz's work. Is this problem D7 specific? I'm mostly focused on the D7 version of the module, so if this problem applies to D6 also, lets backport it. However it seems like everyone here is just talking about D7. Thanks everyone for their input and patience on this one.

HongPong’s picture

This 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.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

dafeder’s picture

Issue summary: View changes

If you're still getting this error and have our node/add page URL aliased, see #2298849: EntityMalformedException missing bundle after clicking Ignore

tisteegz’s picture

Still getting this error when clicking restore, tried on multiple content type forms.

"ResponseText: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7929 of /../includes/common.inc)"

Autosave: 7.x-2.2+17-dev (2016-Jan-20)
Entity: 7.x-1.8
Drupal: 7.56