I have a custom module which performs an edit to the body field of a node in hook_nodeapi when $op is 'presave.' My code edits the body of the node and then that edited body is stored to the DB.

When consequently editing that node, the content presented in the body textarea is incorrect. I have determined that the content presented is the teaser field and then body field of that node. I have no explanation for why that should be presented and I found this report:


describing the same problem and claiming that this is a bug in Drupal 6.x core.

My experience would indicate a similar conclusion--that there is a bug that if the teaser field does not match the first X characters of the body, then the teaser is prepended to the body when editing the node.

This issue can be reproduced very simply by manually editing a record in node_revisions to make the body field begin differently then the teaser field, and then edit the node in the browser. I only tested this in MySQL.


siharris’s picture

I'm encountering the same problem when creating a custom teaser with HTML tags removed.

AlexisWilke’s picture

There is a function in node.pages.inc named node_body_field() that compares the teaser to the beginning of the body. If different, then the teaser is considered separate.

I have a patch for the teaser, but your problem is different... What you'd need to do is re-generate the teaser after you modified the body (i.e. something like this: $node->teaser = node_teaser($node->body);).

#221257: text_summary() should output valid HTML and Unicode text, and not count markup characters as part of the text length

Hope this helps.
Alexis Wilke