Skip to content
Snippets Groups Projects
Commit 071afd42 authored by Dieter Holvoet's avatar Dieter Holvoet
Browse files

Merge branch '3337041-fix-track-changes' into '1.x'

Make sure non-field source properties are not included in the hash

See merge request !3
parents cd21c8c7 ca6e0e86
No related branches found
No related tags found
No related merge requests found
Pipeline #80868 skipped
......@@ -59,27 +59,43 @@ class Queue extends SourcePluginBase implements ContainerFactoryPluginInterface
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
$data = $row->getSourceProperty('data');
$fields = $this->configuration['fields'] ?? [];
$fieldNames = $this->isArrayAssociative($fields)
? array_keys($fields)
: array_values($fields);
// Assign the fields from the data array to the row.
$data = $row->getSourceProperty('data');
foreach ($fieldNames as $field) {
if (array_key_exists($field, $data)) {
$row->setSourceProperty($field, $data[$field]);
}
}
// If processing is not necessary, delete the item from the queue.
// Temporarily unset all non-fields from the source, so they are not included in the hash.
$nonFieldNames = array_diff(array_keys($row->getSource()), $fieldNames);
$nonFieldValues = [];
foreach ($nonFieldNames as $nonFieldName) {
$nonFieldValues[$nonFieldName] = $row->getSourceProperty($nonFieldName);
$row->setSourceProperty($nonFieldName, NULL);
}
// Determine if the row needs processing.
$processRow = parent::prepareRow($row);
// If processing is not necessary, delete the item from the queue.
if ($processRow === FALSE || !$this->needsProcessing($row)) {
$queue = $this->queueFactory->get($row->get('queue_name'));
$item = (object) ['item_id' => $row->get('item_id')];
$queue->deleteItem($item);
}
// Restore the non-field values to the source.
foreach ($nonFieldNames as $nonDataKey) {
$row->setSourceProperty($nonDataKey, $nonFieldValues[$nonDataKey]);
}
return $processRow;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment