diff --git a/modules/salesforce_push/salesforce_push.install b/modules/salesforce_push/salesforce_push.install index 30aab38387262e37517f9e2bc54284fd42b80b0f..99aeff72c959b7148ce0d8878475d8f0124c168a 100644 --- a/modules/salesforce_push/salesforce_push.install +++ b/modules/salesforce_push/salesforce_push.install @@ -62,3 +62,12 @@ function salesforce_push_update_8003() { } \Drupal::state()->delete('salesforce.global_push_limit'); } + +/** + * Updates schema for push queue. + */ +function salesforce_push_update_8004() { + $schema_definition = \Drupal::service('queue.salesforce_push')->schemaDefinition(); + // Adds the new fields to the table. + \Drupal::database()->schema()->addField('salesforce_push_queue', 'last_failure_message', $schema_definition['fields']['last_failure_message']); +} diff --git a/modules/salesforce_push/src/PushQueue.php b/modules/salesforce_push/src/PushQueue.php index a07021685b5dd672774d069ba497f027aed3bf13..91659c1f6ef7c47e48b65047576aad531060d832 100644 --- a/modules/salesforce_push/src/PushQueue.php +++ b/modules/salesforce_push/src/PushQueue.php @@ -244,6 +244,9 @@ class PushQueue extends DatabaseQueue implements PushQueueInterface { 'failures' => empty($data['failures']) ? 0 : $data['failures'], + 'last_failure_message' => empty($data['last_failure_message']) + ? '' + : $data['last_failure_message'], 'mapped_object_id' => empty($data['mapped_object_id']) ? 0 : $data['mapped_object_id'], @@ -364,6 +367,12 @@ class PushQueue extends DatabaseQueue implements PushQueueInterface { 'default' => 0, 'description' => 'Number of failed push attempts for this queue item.', ], + 'last_failure_message' => [ + 'type' => 'text', + 'not null' => FALSE, + 'default' => NULL, + 'description' => 'The last failure message for this queue item, if failed.', + ], 'expire' => [ 'type' => 'int', 'not null' => TRUE, @@ -525,10 +534,10 @@ class PushQueue extends DatabaseQueue implements PushQueueInterface { $message = $e->getMessage(); if ($item->failures >= $this->maxFails) { - $message = 'Permanently failed queue item %item failed %fail times. Exception while pushing entity %type %id for salesforce mapping %mapping. ' . $message; + $item->last_failure_message = 'Permanently failed queue item %item failed %fail times. Exception while pushing entity %type %id for salesforce mapping %mapping. ' . $message; } else { - $message = 'Queue item %item failed %fail times. Exception while pushing entity %type %id for salesforce mapping %mapping. ' . $message; + $item->last_failure_message = 'Queue item %item failed %fail times. Exception while pushing entity %type %id for salesforce mapping %mapping. ' . $message; } $args = [ '%type' => $mapping->get('drupal_entity_type'), @@ -537,7 +546,7 @@ class PushQueue extends DatabaseQueue implements PushQueueInterface { '%item' => $item->item_id, '%fail' => $item->failures, ]; - $this->eventDispatcher->dispatch(new SalesforceErrorEvent(NULL, $message, $args), SalesforceEvents::ERROR); + $this->eventDispatcher->dispatch(new SalesforceErrorEvent(NULL, $item->last_failure_message, $args), SalesforceEvents::ERROR); // Failed items will remain in queue, but not be released. They'll be // retried only when the current lease expires.