I’ve been working on this. I’ve made some progress, but now I’m stuck.
What I’ve done so far:
The language wasn’t included during resource processing, when filling property values. In /BulkImport/src/Processor/ResourceProcessor.php, I made 2 changes. I added a condition for the ‘html’ data type in fillProperty() and in fillPropertyForValue()
This is where I’m stuck:
Somehow the language is dropped during entity creation.
Here’s the function where I notice the language disappear.
It’s within createEntity() in BulkImport/src/Processor/AbstractResourceProcessor.php
protected function createEntity(array $resource): ?AbstractEntityRepresentation{
// Linked ids from identifiers may be missing in data. So two solutions
// to add missing ids: create resources one by one and add ids here, or
// batch create and use an event to fill add ids.
// In all cases, the ids should be stored for next resources.
// The batch create in api adapter is more a loop than a bulk process.
// The main difference is the automatic detachment of new entities,
// instead of a clear. In doctrine 3, detachment will be removed.
// So act as a loop.
// Anyway, in most of the cases, the loop contains only one resource.
// And in fact, there is no more loop, but a single resource.
$defaultResourceName = $this->getResourceName();
// Manage mixed resources.
$resourceName = $resource['resource_name'] ?? $defaultResourceName;
$resource = $this->bulkIdentifiers->completeResourceIdentifierIds($resource);
// Remove uploaded files for items.
foreach ($resource['o:media'] ?? [] as $key => $media) {
if (($media['o:ingester'] ?? null )=== 'bulk' && ($media['ingest_ingester'] ?? null) === 'upload') {
$resource['o:media'][$key]['ingest_delete_file'] = true;
}
}
try {
$response = $this->bulk->api(null, true)
->create($resourceName, $resource);
} catch (ValidationException $e) {
$resource['messageStore']->addError('resource', new PsrMessage(
'Error during validation of the data before creation.' // @translate
));
$messages = $this->listValidationMessages($e);
$resource['messageStore']->addError('resource', $messages);
$this->bulkCheckLog->logCheckedResource($this->indexResource, $resource);
++$this->totalErrors;
return null;
} catch (\Exception $e) {
$resource['messageStore']->addError('resource', new PsrMessage(
'Core error during creation: {exception}', // @translate
['exception' => $e]
));
$this->bulkCheckLog->logCheckedResource($this->indexResource, $resource);
++$this->totalErrors;
return null;
}
$representation = $response->getContent();
$this->bulkIdentifiers->storeSourceIdentifiersIds($resource, $representation);
if ($representation->resourceName() === 'media') {
$this->logger->notice(
'Index #{index}: Created media #{media_id} (item #{item_id})', // @translate
['index' => $this->indexResource, 'media_id' => $representation->id(), 'item_id' => $representation->item()->id()]
);
} else {
$this->logger->notice(
'Index #{index}: Created {resource_name} #{resource_id}', // @translate
['index' => $this->indexResource, 'resource_name' => $this->easyMeta->resourceLabel($resourceName), 'resource_id' => $representation->id()]
);
}
return $representation;
}
At line 1218, the language is present in $resource:
$response = $this->bulk->api(null, true)
->create($resourceName, $resource);
When I log $resource, its contents look like this:
{"resource":"{\"resource_name\":\"items\",\"o:id\":null,\"source_index\":1,\"checked_id\":true,\"o:owner\":{\"o:id\":1},\"o:is_public\":true,\"o:item_set\":[],\"o:media\":[],\"dcterms:title\":[{\"type\":\"literal\",\"property_id\":1,\"is_public\":true,\"@value\":\"Jesús Sánchez Erazo [Chuíto el de Bayamón]\",\"o:lang\":null}],\"dcterms:description\":[{\"type\":\"uri\",\"property_id\":4,\"is_public\":true,\"@id\":\"https://www.geonames.org\",\"o:label\":null,\"o:lang\":\"es\"},{\"type\":\"html\",\"property_id\":4,\"is_public\":true,\"@value\":\"<p>Jesús Sánchez Erazo, known as Chuíto el de Bayamón, was born in 1900 in Bayamón, Puerto Rico. His upbringing stressed the importance of music and working the land. Sánchez Erazo was a <em>trovador</em> and based his <em>décimas</em> (ten octosyllabic poetic stanzas) on everyday life and scenes from rural Puerto Rico. He began his career in a bolero duo with Beno, a guitarist and popular music singer. At the same time, he started performing <em>décimas</em> as a soloist and competing with troubadours at patron saint festivals in various municipalities. </p>\",\"o:lang\":\"en\"}],\"has_error\":false,\"messageStore\":{}}"
Then, at line 1239, the language is missing in $representation:
$representation = $response->getContent();
When I log $representation, its contents looks like this:
"representation":"object(Omeka\\Api\\Representation\\ItemRepresentation) {\"@context\":\"https:\\/\\/domain.com\\/api-context\",\"@id\":\"https:\\/\\/domain.com\\/api\\/items\\/215\",\"@type\":\"o:Item\",\"o:id\":215,\"o:is_public\":true,\"o:owner\":{\"@id\":\"https:\\/\\/domain.com\\/api\\/users\\/1\",\"o:id\":1},\"o:resource_class\":null,\"o:resource_template\":null,\"o:thumbnail\":null,\"o:title\":\"Jes\\u00fas S\\u00e1nchez Erazo [Chu\\u00edto el de Bayam\\u00f3n]\",\"thumbnail_display_urls\":{\"large\":null,\"medium\":null,\"square\":null},\"o:created\":{\"@value\":\"2025-02-27T18:42:19+00:00\",\"@type\":\"http:\\/\\/www.w3.org\\/2001\\/XMLSchema#dateTime\"},\"o:modified\":{\"@value\":\"2025-02-27T18:42:19+00:00\",\"@type\":\"http:\\/\\/www.w3.org\\/2001\\/XMLSchema#dateTime\"},\"o:primary_media\":null,\"o:media\":[],\"o:item_set\":[],\"o:site\":[{\"@id\":\"https:\\/\\/domain.com\\/api\\/sites\\/1\",\"o:id\":1},{\"@id\":\"https:\\/\\/domain.com\\/api\\/sites\\/2\",\"o:id\":2}],\"dcterms:title\":[{\"type\":\"literal\",\"property_id\":1,\"property_label\":\"Title\",\"is_public\":true,\"@value\":\"Jes\\u00fas S\\u00e1nchez Erazo [Chu\\u00edto el de Bayam\\u00f3n]\"}],\"dcterms:description\":[{\"type\":\"uri\",\"property_id\":4,\"property_label\":\"Description\",\"is_public\":true,\"@id\":\"https:\\/\\/www.geonames.org\",\"o:lang\":\"es\"},{\"type\":\"html\",\"property_id\":4,\"property_label\":\"Description\",\"is_public\":true,\"@value\":\"<p>Jesús Sánchez Erazo, known as Chuíto el de Bayamón, was born in 1900 in Bayamón, Puerto Rico. His upbringing stressed the importance of music and working the land. Sánchez Erazo was a <em>trovador<\\/em> and based his <em>décimas<\\/em> (ten octosyllabic poetic stanzas) on everyday life and scenes from rural Puerto Rico. He began his career in a bolero duo with Beno, a guitarist and popular music singer. At the same time, he started performing <em>décimas<\\/em> as a soloist and competing with troubadours at patron saint festivals in various municipalities. <\\/p>\",\"@type\":\"http:\\/\\/www.w3.org\\/1999\\/02\\/22-rdf-syntax-ns#HTML\"}]}
I can’t figure out where the representation is created. If I knew this, then maybe I could figure out what goes wrong in the process.
Thanks for reading this post and thanks in advance for any suggestions.