Allow orphan cleanup of draft distributions. #3979
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In sites where datasets and their referenced distributions are all created as draft nodes (like PDC), we've seen a build up of orphan_reference_processor queue items.
This is because prior to this PR, the MetastoreService would only ever retrieve published node revisions - even when getting an orphaned distribution for cleanup.
Since many of the distribution nodes were never published (due to initially being created as a draft) this results in "Error retrieving metadata: distribution {$uuid} not found." being thrown for all distributions being cleaned up that were never published.
This PR adds an optional boolean parameter to MetastoreService::get() to allow it to retrieve unpublished distributions when it is called by cleanResourceMapperTable().
To recreate in a vanilla DKAN site:
To confirm this patch fixes the error, apply the patch, follow the steps above, and do not receive an error. The resource file directory and datastore table are also deleted successfully.