The website encountered an unexpected error

Created on 7 September 2023, 10 months ago
Updated 5 October 2023, 9 months ago

Problem/Motivation

When removing entity type in the config and visiting pages that were viewed, you get an error:
InvalidArgumentException: A valid cache entry key is required. Use getAll() to get all table data. in Drupal\views\ViewsData->get() (line 140 of core/modules/views/src/ViewsData.php).
In the logs, you also get a warning:
Warning: Undefined array key "base" in Drupal\views\Plugin\views\query\QueryPluginBase->getEntityTableInfo() (line 302 of /var/www/html/web/core/modules/views/src/Plugin/views/query/QueryPluginBase.php)

Steps to reproduce

  1. Install module
  2. Visit pages of type node (article/page)
  3. Disable entity type Content in recently read configuration
  4. Visit the same pages as in the second point
🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @admirlju
  • @admirlju opened merge request.
  • Status changed to Needs work 10 months ago
  • The problem was related to the demo block view, when an entity type of node was removed from a recently read there would be a non-existent relationship. For now, if an entity type is disabled, the code also disables the view.

    Will have to add a warning that the view got disabled and check if someone tries to enable it when the entity type is disabled for recently read.

  • When we disable the recently read entity type, the relationship doesn't exist anymore, so before disabling the view I also remove that specific relationship. If there are existing blocks for the view, those are now also removed. When views get disabled or blocks removed I now display a warning.

  • Status changed to Needs review 10 months ago
  • Rebased the repository, to make it easier for maintainers. Switching status to Needs Review.

  • First commit to issue fork.
  • 🇸🇮Slovenia DeaOm

    Removed the part of code, that removes the relationship from view, as that means that users can't place a block anymore even if they set the content types again, if they do not add a relationship back again or disable and then enable the module again. The block gets deleted/removed from being placed so it's no longer present on the page and therefore there is no error when revisiting pages that were added to the block basically. If users decide to again place the block, they can do so, by first setting entity type back in the configuration. If they do not, the same problem appears. Not sure if this should be handled here or not, to not allow placing a block if there were entities already added. Leaving it open for discussion.

  • I still believe we should at least disable the view, so the admin doesn't even have an option to re-add the block. And if need be the admins can enable the previously disabled views.

    Also personally the default view you get at install feels like a demo view, that admins can use as reference, how to make for any other entity.

  • Status changed to Needs work 9 months ago
  • Also looking at the changes now it will delete any block, that is made with the View module, that has any relationship (not just recently_read relationships).

  • Status changed to Needs review 9 months ago
Production build 0.69.0 2024