Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File usage on uploaded files is not captured correctly #3721

Open
janette opened this issue Dec 2, 2021 · 0 comments
Open

File usage on uploaded files is not captured correctly #3721

janette opened this issue Dec 2, 2021 · 0 comments
Assignees
Labels

Comments

@janette
Copy link
Member

janette commented Dec 2, 2021

Currently the file usage is tied to a non-existent entity type (json_form_widget) and the users id.

  1. This causes an error when clicking on the usage link in /admin/content/files - See error below.

  2. When a dataset is deleted, it's distributions are set to unpublished. If an administrator deletes these distribution nodes, the usage is not updated to 0, the original usage remains, making it impossible to delete the files properly from the server.

To Dos:

  1. Uploaded file usage should be assigned to the entity type "node", and distribution node ID rather than "json_form_widget" and user ID.
  2. To clean up existing sites, we would need a hook to fix the existing usage records.
  3. There should also be a config setting to automate deletion of files when the usage is at 0.
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "json_form_widget" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 143 of core/lib/Drupal/Core/Entity/EntityTypeManager.php).

Drupal\Core\Entity\EntityTypeManager->getHandler('json_form_widget', 'storage') (Line: 196)
Drupal\Core\Entity\EntityTypeManager->getStorage('json_form_widget') (Line: 139)
Drupal\views\Plugin\views\field\EntityLabel->preRender(Array) (Line: 1503)
Drupal\views\ViewExecutable->render() (Line: 183)
Drupal\views\Plugin\views\display\Page->execute() (Line: 1630)
Drupal\views\ViewExecutable->executeDisplay('page_2', Array) (Line: 81)
Drupal\views\Element\View::preRenderViewElement(Array)
call_user_func_array(Array, Array) (Line: 101)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 786)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 377)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 201)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 241)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 578)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 49)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 717)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Unable to delete a file uploaded by the dataset form

The file data.csv cannot be deleted because it is in use by the following modules: json_form_widget.
@janette janette added the bug label Dec 2, 2021
@github-actions github-actions bot added this to Incoming/Triage in DKAN 2 Issue Triage Dec 2, 2021
@janette janette changed the title "json_form_widget" entity type does not exist File usage on uploaded files is not captured correctly Dec 10, 2021
@dafeder dafeder self-assigned this Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
DKAN 2 Issue Triage
  
Incoming/Triage
Development

No branches or pull requests

2 participants