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:
- 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.
- Partial Update Logic: When a user saves a resource, the backend triggers a save for the parent package.
- 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.
- 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
- Initial State:
- A dataset is saved while the UI is in Italian.
- The core
package.title column now physically holds the Italian string.
- Switch Language:
- The user switches the site language to German.
- The UI correctly displays the German title (fetched from
package_multilang).
- Trigger the Bug:
- The user edits a Resource (e.g., changes a resource URL or description) and clicks "Save."
- 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.
Summary
There is a critical synchronization issue in
ckanext-multilangwhere 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:
package) only store the "last saved" version of a field. The extension stores all versions inpackage_multilang.packagetable to complete the object.package_multilangentry for the current session (German), effectively overwriting German with Italian.Reproduction Scenario
package.titlecolumn now physically holds the Italian string.package_multilang).package_multilangis overwritten with the Italian text.Expected Behavior
When a resource is updated, the backend should either:
Impact
Users lose localized data silently whenever they perform unrelated edits to resources.