Skip to content

Commit

Permalink
Fix jobstore error when dropping datastore using Drush. (#3695)
Browse files Browse the repository at this point in the history
  • Loading branch information
Clayton Liddell committed Nov 8, 2021
1 parent 97107de commit 5d58599
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
14 changes: 11 additions & 3 deletions modules/datastore/src/Drush.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,22 @@ private function createRow($uuid, $item) {
* Drop a datastore.
*
* @param string $uuid
* The uuid of a dataset.
* The uuid of a dataset resource.
*
* @command dkan:datastore:drop
* @aliases dkan-datastore:drop
* @deprecated dkan-datastore:drop is deprecated and will be removed in a future Dkan release. Use dkan:datastore:drop instead.
*/
public function drop($uuid) {
try {
// Retrieve the UUID for the dataset's resource before dropping the
// dataset's resource mapper table entry.
$resource = $this->resourceLocalizer->get($uuid);
if (!isset($resource)) {
throw new \UnexpectedValueException("Resource not found with uuid {$uuid}");
}
$resource_uuid = $resource->getUniqueIdentifier();
// Drop the datastore table and corresponding resource mapper table entry.
$this->datastoreService->drop($uuid);
$this->logger->notice("Successfully dropped the datastore for {$uuid}");
}
Expand All @@ -168,8 +176,8 @@ public function drop($uuid) {
$this->logger->debug($e->getMessage());
return;
}

$this->jobstorePrune($uuid);
// Drop any remaining jobstore entries for this resource.
$this->jobstorePrune($resource_uuid);
}

/**
Expand Down
8 changes: 1 addition & 7 deletions modules/datastore/src/TableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ trait TableTrait {
/**
* Delete jobstore entries related to a datastore.
*/
public function jobstorePrune($uuid) {
if (!isset($this->resourceLocalizer)) {
\Drupal::logger('datastore')->error('ResourceLocalizer is not set.');
return;
}
$resource = $this->resourceLocalizer->get($uuid);
$ref_uuid = $resource->getUniqueIdentifier();
public function jobstorePrune($ref_uuid) {
$jobs = [
[
"id" => substr(str_replace('__', '_', $ref_uuid), 0, -11),
Expand Down

0 comments on commit 5d58599

Please sign in to comment.