1

I am experiencing a pretty serious problem leading to data-loss in D7. Editing any existing node leads to empty body content and newly created nodes have no body content whatsoever.

Update: The error is reproducibly linked to the Locale module (v 7.78), disabling Locale leads to normal behavior, enabling it leads to data-loss when editing.

However, Locale has been enabled for a long time, so I am suspecting one of the updates since May 2020 (last time new content was added without problems) introduced a bug or a failed database update. So, there might be a bug in Locale that only shows under certain circumstances, e.g. PostgreSQL, a site migrated from D6 or Locale activated after content was already created, ...

The following observations are with Locale enabled:

Tracking an existing node in Postgres shows the node body content in field_data_body before an edit. After an edit, field_data_body has no entry with the entity_id. I can put back the data using SQL and then the body content is displayed. Newly created nodes never get an entry in field_data_body.

Therefore, I am suspecting something might be odd with HTML filtering (Filtered HTML, Plain text, ...) or the content edit form or language settings.

This is the original data of an existing node:

select * from field_data_body where entity_id = 745959;
 entity_type | bundle | deleted | entity_id | revision_id | language | delta |           

    body_value               | body_summary | body_format
-------------+--------+---------+-----------+-------------+----------+-------+----------------------------------------+--------------+-------------
 node        | blog   |       0 |    745959 |      745959 | und      |     0 | The genome browser is not working TEST |              | 1

After editing:

select * from field_data_body where entity_id = 745959;
 entity_type | bundle | deleted | entity_id | revision_id | language | delta | body_value | body_summary | body_format
-------------+--------+---------+-----------+-------------+----------+-------+------------+--------------+-------------
(0 rows)

Also, the node.language and field language are different:

select nid, n.language as "node-language", b.language as "field-language" from node as n left join field_data_body as b on n.nid=b.entity_id  where nid = 745959;
  nid   | node-language | field-language
--------+---------------+----------------
 745959 | en            | und
(1 row)

Looks like it could indeed be a language setting conflict. When looking at the $form data, the values entered into body are found as such and only there.

So it indeed appears to be a language setting problem:

  • create a new Page node: node.language is initially set to "en", the site default, no body data entry is created or saved upon edit (in form_data_body)
  • In postgres, change node.language to "und"
  • The body content is now saved upon edit and displayed properly

1 Answer 1

0

Implement hook_form_submit() and either set a breakpoint there, output to the messages or log the form_state values to see what's actually being submitted. Implement hook_node_presave() and do the same to see what's actually going to be saved to the database.

There is a chance the client-side JS or some validation hook changes the value for the field, so you will have to either dig or debug through all your modules. It's hard to tell something specifically, because any module, either contrib or custom one, can put its own hook and empty the content for some reason.

1
  • Hi, I have found that it is really linked to the different language settings. Looks like setting default language to "en" insead of und might have caused the problem.
    – Michael
    Mar 13, 2021 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.