- Issue created by @gugalamaciek
- 🇵🇱Poland gugalamaciek
The patch adds an additional sort by language code when the entity type supports translations.
I encountered issues with bulk processing of entities that have translations. Specifically, when processing such entities, the bulk operation was sometimes triggered on the original entity instead of on the correct translation.
In my case, I was working with taxonomy terms:
After further investigation, I found that the issue is likely caused by the implementation of ViewsBulkOperationsActionProcessor::getPageList(). This function replaces existing sorts with a single sort on the base field:
// In some cases we may encounter nondeterministic behaviour in
// db queries with sorts allowing different order of results.
// To fix this we're removing all sorts and setting one sorting
// rule by the view base id field.
foreach (\array_keys($this->view->getHandlers('sort')) as $id) {
$this->view->setHandler($this->bulkFormData['display_id'], 'sort', $id, NULL);
}
$this->view->setHandler($this->bulkFormData['display_id'], 'sort', $base_field, [
'id' => $base_field,
'table' => $base_table,
'field' => $base_field,
'order' => 'ASC',
'relationship' => 'none',
'group_type' => 'group',
'exposed' => FALSE,
'plugin_id' => 'standard',
]);However, for entity types that support translations, sorting by the base field is insufficient because it may not be unique across translations. As a result, the database query can return results in a non-deterministic order.
Introduce a check to determine if the entity type supports translations. If it does, add an additional sort by language code (langcode) to ensure consistent and deterministic query results.
Active
4.3
Core
The patch adds an additional sort by language code when the entity type supports translations.