The Linux Page

Drupal 6 and the <!--break--> comment

An Axe to Cut Trees

The <!--break--> comment has been used by Drupal to seperate the part of the text to show as a summary of your post and the rest.

That summary is often used on your front page, list views, etc.

The problem is that at times it breaks the editor. Something goes wrong and you just can't edit the post anymore.

To fix the problem, remove the break. Oh! But...

Effectively, you can't edit the post if it has a break so you can't edit the post to remove the break. At least not easily. That is, you could copy the part before the break and then edit and then paste. If you have things such as an image, special formatting, etc. it's not likely to work just like that.

So what to do?

The easiest and most effective way I've found to do this is to do it using the REPLACE() function in PostgreSQL. I suppose you have an equivalent in MySQL if you are using that other database (or whatever DB is supported).

The full command goes like this:

UPDATE node_revisions SET body = REPLACE(body, '<!--break-->', '') WHERE nid = 123;

The body field is defined in the node_revisions table, so that's the one we update.

Then we use the REPLACE() command and transform the <!--break--> with an empty string.

In this example I use a WHERE clause to only tweak that one post. However, if you have problems with that feature, you're likely to need to fix all your posts and thus you should not use the WHERE clause.