Skip to content

Commit

Permalink
Fix import queue job message labels. (#3776)
Browse files Browse the repository at this point in the history
  • Loading branch information
dafeder committed May 27, 2022
1 parent f5b6857 commit 5edbb33
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions modules/datastore/src/Plugin/QueueWorker/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ protected function importData(array $data) {
$results = $this->datastore->import($identifier, FALSE, $version);

$queued = FALSE;
foreach ($results as $result) {
$queued = isset($result) ? $this->processResult($result, $data, $queued) : FALSE;
foreach ($results as $label => $result) {
$queued = isset($result) ? $this->processResult($result, $data, $queued, $label) : FALSE;
}

// Delete local resource file if enabled in datastore settings config.
Expand All @@ -189,29 +189,31 @@ protected function importData(array $data) {
* The resource data for import.
* @param bool $queued
* Whether the import job is currently queued.
* @param string $label
* A label to distinguish types of jobs in status messages.
*
* @return bool
* The updated value for $queued.
*/
protected function processResult(Result $result, $data, $queued = FALSE) {
protected function processResult(Result $result, $data, bool $queued = FALSE, string $label = 'Import') {
$uid = "{$data['identifier']}__{$data['version']}";
$status = $result->getStatus();
switch ($status) {
case Result::STOPPED:
if (!$queued) {
$newQueueItemId = $this->requeue($data);
$this->notice("Import for {$uid} is requeueing. (ID:{$newQueueItemId}).");
$this->notice("$label for {$uid} is requeueing. (ID:{$newQueueItemId}).");
$queued = TRUE;
}
break;

case Result::IN_PROGRESS:
case Result::ERROR:
$this->error("Import for {$uid} returned an error: {$result->getError()}");
$this->error("$label for {$uid} returned an error: {$result->getError()}");
break;

case Result::DONE:
$this->notice("Import for {$uid} completed.");
$this->notice("$label for {$uid} completed.");
$this->invalidateCacheTags("{$uid}__source");
break;
}
Expand Down

0 comments on commit 5edbb33

Please sign in to comment.