body/teaser mismatch duplicating node header
| Project: | Search and Replace |
| Version: | 6.x-1.1-beta4 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | needs work |
Jump to:
We often use a sql script to update the body text of a node. When the body of a node is updated it leaves the body and the teaser out of sync (not matching).
When such a page is opened in the editor the teaser is copied into the body duplicating the top of the page,
A node containing this:
Test Page
this is somd other text
is updated to
TTTT PPPP
this is somd other text
This leaves the body with the new text but the teaser with the old content.
When the node is opened with the editor, this is presented:
Test Page
this is somd other text
TTTT PPPP
this is somd other text
The teaser is added to the front of the page showing both the original content and the new content.
This happens if SQL is used or if the "search_and_replace" module is used for the update.
We are using FCKEditor as a node editing tool so I am not sure where the duplication is actually performed.
It happens more often if the top of the page contains html code (header tags or image tags).
It initially happened when we had nodes with
tags at the top of several pages. We updated all of the
to
using a sql script. Opening the updated page presented the new
and content along with the old
and content. The teaser which contained the old text was added to the node being edited showing both new text and old text.
using a sql script. Opening the updated page presented the new
and content along with the old
and content. The teaser which contained the old text was added to the node being edited showing both new text and old text.
and content. The teaser which contained the old text was added to the node being edited showing both new text and old text.
Thanks
Emery Gordon

#1
ummm.... I'm a bit confused by all the text you've added with this post but am I to believe that the Teaser isn't having the replacement / search applied to it? If this is the case I can work on fixing it, just need to make sure first.
#2
That is absolutely the case. The teaser is not updated and when Drupal opens the page for editing it will copy the teaser into the page which now shows the original text and the teaser.
This is happening with or without the FCKEditor.
It appears to be a bug in Drupal itself. I can't imagine why it would think that if the body and teaser are different it should copy the teaser into the body.
To test:
create a page with an h tag and text
update the text with search_and_replace
SQL will show that the text in the body and teaser is different
Reopen the page and you will see the duplicated headers.
Thanks
#3
This is for effiicency's sake in Drupal. It creates the Teaser during node saves kicked off by the form submission (the invoking of node_save if that makes any sense). I'm not sure why it wouldn't update the teaser based on this information but maybe it is a "glitch" (sorta) in Drupal. The search and replace module will have to take this into account then I guess.
I don't use Teasers very often so I wouldn't think of this :)
It'll probably be something like the following that needs to be added to the replacement of body code:
$node->body['#teaser']['value'] = str_replace($search,$replace,$node->body['#teaser']['value']);#4
I am sorry, but this is a bug and it is critical.
In the current form the module is not suitable for any site with any meaningful amount of content. Teasers are used widely and are a default setting in Drupal. This means a few Search/Replace actions, followed by some "unsupervised" editing by users can lead to some serious damage to content.
The easiest solution (for sites that did not get their content messed up, YET) is to update the module to run exact same replacement action on the teaser, as on the body. Of course, there is still risk that search/replace pattern would occur across teaser break, but this is better than nothing. An alternative would be to re-generate and overwrite teasers the same way Drupal does by default (using
node_teaserfunction), but make this an option for user who runs search/replace. Perhaps both options (as well as an option to remove teaser or do nothing about it) should be offered in the admin screen.As for all those unfortunate souls who have to deal with body/teaser mismatch after the fact... You could fix content by hand, roll back revisions, wipe out teasers by script or by hand or perhaps write some custom recovery script. Either option is pretty ugly. This root cause needs to be fixed.
#5
OK, let me just say that I evaluated a competing module and it solved all of the above problems: http://drupal.org/project/scanner
I was able to do search/replace specifically on teasers and bring them in sync with node bodies. Looks like the Scanner has a lot more powerful functionality, including automatic teaser generation from updated node bodies.
Not sure what this (Search and Replace) module has that Scanner does not. Perhaps these two projects should be merged?
#6
scanner does things at a database level which is far more dangerous cause there's no rolling back. node_save uses revisions and has a history that could be undone if needed (fundamental difference).
#7
Scanner also generates revisions now, allows to preview / diff your changes before accepting them and lets you narrow down targeting by preceding / succeeding content. I suggest you take a look at their latest. One thing is sure - saved me lots of time finding problems in my teasers and fixing them.
At the very least, it might be helpful to have updated documentation comparing the modules.