Skip to content

Resource updates cause package-level translation corruption #48

Description

@etj

Summary

There is a critical synchronization issue in ckanext-multilang where updating a resource causes the package (dataset) translations for the current language to be overwritten by stale data from the core CKAN tables.

The frontend correctly displays the localized text, but the backend update logic defaults to reading from core SQL tables instead of the multilang extension tables when rebuilding the package object.


Technical Root Cause

The corruption occurs because of how the backend handles the package object during a resource update:

  1. Core Table vs. Multilang Table: CKAN core tables (package) only store the "last saved" version of a field. The extension stores all versions in package_multilang.
  2. Partial Update Logic: When a user saves a resource, the backend triggers a save for the parent package.
  3. The "Fill-in" Failure: If the package fields (title, notes, etc.) are not part of the specific resource update payload, the backend fetches the "current" values from the core package table to complete the object.
  4. Language Mismatch: This fetch retrieves the raw value from the core table (e.g., text in Italian) regardless of the user's current session language (e.g., German). The extension then sees this "new" text and updates the package_multilang entry for the current session (German), effectively overwriting German with Italian.

Reproduction Scenario

  1. Initial State:
    • A dataset is saved while the UI is in Italian.
    • The core package.title column now physically holds the Italian string.
  2. Switch Language:
    • The user switches the site language to German.
    • The UI correctly displays the German title (fetched from package_multilang).
  3. Trigger the Bug:
    • The user edits a Resource (e.g., changes a resource URL or description) and clicks "Save."
  4. Resulting Corruption:
    • The backend saves the resource.
    • Simultaneously, it fetches the package title from the core table (which is in Italian).
    • The plugin interprets this as a German update (since the session is German).
    • The German entry in package_multilang is overwritten with the Italian text.

Expected Behavior

When a resource is updated, the backend should either:

  • Ignore package-level fields if they are not present in the update request.
  • Ensure that any automated fetch of package metadata for the update object is passed through the multilang logic to retrieve the correct localized string for the current session.

Impact

Users lose localized data silently whenever they perform unrelated edits to resources.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions