When updating fields, not all languages could be deleted as expected

Created on 4 May 2022, over 2 years ago
Updated 10 May 2022, over 2 years ago

Problem/Motivation

field_sql_storage_field_storage_write() updates the fields by deleting and then inserting the new values again.
When languages are involved, there can be cases when not every row for every language is actually deleted, which leads to leftovers which can result in unexpected behaviors.

Steps to reproduce

A way to replicate this is to use the drafty/cps modules:
- set a field as translatable
- import the content as LANGUAGE_NONE (which is an error, but can happen)
- create a site version in cps
- edit and save the content (do not publish the site version)

The end result in the `field_data` table will be that you'll have two rows, one for LANGUAGE_NONE and one for the form language (e.g. "en"). The "en" row though will be the last updated, which should have been removed instead (which leads to content being published in cps even without publishing the site version).

Proposed resolution

Patch field_sql_storage_field_storage_write() to address this case.

Remaining tasks

Fix and test.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

Fixed remote case where field content could not be updated correctly.

🐛 Bug report
Status

RTBC

Version

7.0 ⚰️

Component
Field 

Last updated 1 day ago

Created by

🇮🇹Italy marco

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024