grahl/ch

Drupal7: Empty nodes or comments after upgrade

content stolen by pirate ghosts

If you are trying to upgrade a site running Drupal 6 to 7 and have messed around with your language settings or input formats, you might be in for a surprise. So, if you are seeing nodes or comments which have a title but an empty body on view and edit, it makes sense to check for the following.

If you have turned the locale module off entirely, but you still have content which is not classified as language neutral, it’s likely that you will now encounter problems. This could probably also happen if you have locale enabled but your specific language is not configured. Let’s presume you do not want to enable the locale module. Missing input formats for content which still has it assigned can be similarly problematic.

In either case, the problem can be solved quickly by adjusting a few rows by hand. If you are familiar with the Drupal 6 table layout and, for example, expect text bodies to show up in node_revisions, you’ll be in for a surprise, since the database schemas have changed in several important areas.

Therefore, you’ll find a primer below the warning on where to find text body specific definitions for input formats and languages for nodes and comments in Drupal 7.

Big fat warning: Of course you need an sql-dump so you can restore your database when you make a typo.

Locale

Reset comments to language neutral and set nodes with language ‘de’ to ‘und’ (i.e. language neutral):

UPDATE comment SET language="und";
UPDATE field_data_comment_body SET language="und";
UPDATE node SET language="und" WHERE language="de";
UPDATE field_data_body SET language="und" WHERE language="de";

Input format

Switches input format from 3 to 1 for all nodes and comments:

UPDATE field_data_comment_body SET comment_body_format=1 WHERE comment_body_format=3;
UPDATE field_data_body SET body_format=1 WHERE body_format=3;

A quick drush cc all is definitely encouraged since the menu cache is at the very least affected when it comes to localized url aliases. Case in point: the language specific alias vanished for content which I switched back to ‘und’ and the page could now be found under node/123.