Problem/Motivation

In #2862041: Provide useful Views filters for Content Moderation State fields, I noticed that a view with a missing/broken filter handler returns results as if the filter were not there. This could be dangerous because the filter could have been limiting results in a way that is now bypassed.

Proposed resolution

I thought that #2212081: Remove views optional handler handling or #1879774: Catch plugin exceptions for invalid views display plugins had made it so that views with broken handlers returned no results, but the scope of those issues is different. The first issue simply removed the optional handlers and let the view to continue to work; the second was only for display plugins, not all handlers.

We should discuss whether the view should return no results in this bad data integrity scenario, whether it should be disabled somehow, whether it should actually be throwing an error, etc.

Making the view return no results could be very disruptive, because if existing sites have broken handlers then updating to a release where this was fixed would make pages that were returning content suddenly return no content. Throwing an error to end users would be even more disruptive. So I'm not really sure what to do here.

Remaining tasks

TBD

User interface changes

TBD

API changes

TBD

Data model changes

TBD

Comments

xjm created an issue. See original summary.

dawehner’s picture

Making the view return no results could be very disruptive, because if existing sites have broken handlers then updating to a release where this was fixed would make pages that were returning content suddenly return no content. Throwing an error to end users would be even more disruptive. So I'm not really sure what to do here.

There are all really good points, mhhh

Here is just a list of further ideas we might or might not apply partially ...

  • Trigger an error. Production sites will not see them, other sites will, hopefully have enabled them
  • Always at least provide some logging
  • We could have a flag for more paranoid sites to opt into returning no results
  • Could we do some validation everytime someone executes a config import? I would personally deny importing configuration which might cause a broken view, like for example when you uninstall a module, but the view, for whatever reason, didn't had the dependencies in the first place?

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Sam152’s picture

This issue has come up again in #2915383: The moderation_state base field is added to all revisionable entity types even if they do not have moderation enabled as a potential blocker. Another idea might be an error on the status report?

Sam152’s picture

Making the view return no results could be very disruptive, because if existing sites have broken handlers then updating to a release where this was fixed would make pages that were returning content suddenly return no content.

Some additional ideas to minimise this disruption would be to decide which plugins are concerned with integrity/access and only hide results if those are broken. I think if we can combine that with an obvious status report entry with a clear message on how to resolve the issue, it could be an acceptable behavioral change. Where a handler is broken and no longer relevant, a user is required to edit and remove the offending plugin. Where a handler is broken incorrectly, it's a good prompt to review the view for integrity issues.

The handlers I'd consider access/integrity concerned are:

  • access
  • argument
  • argument_default
  • argument_validator
  • cache
  • display_extender
  • exposed_form
  • filter
  • join
  • query
  • relationship

It would be great to get some further input on this.

Lendude’s picture

There is only a limited number of 'broken' handlers, any other handler type that has a missing plugin will just break/fatal.

If I remove the 'none' access handler:
The website encountered an unexpected error. Please try again later.Drupal\Component\Plugin\Exception\PluginNotFoundException: The "none" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

So this would only apply to handlers that we actually provide a broken handler for:
\Drupal\views\Plugin\views\relationship\Broken
\Drupal\views\Plugin\views\field\Broken
\Drupal\views\Plugin\views\sort\Broken
\Drupal\views\Plugin\views\argument\Broken
\Drupal\views\Plugin\views\filter\Broken
\Drupal\views\Plugin\views\area\Broken

The fact that Views allows you to work with broken config in the first place is incredibly lenient. It's broken, so break.... I don't know of any other config entity that actually allows you to work with it while it's knowingly broken.

This might be too radical for D8 but I could definitely get behind deprecating the broken handlers and the underlying logic that provides that fall back. It's broken, we know it's broken, you know it's broken, fix it and be merry!

Once we have #2832558: Add a 'disabled' section to config changes page when removing config I like @xjms idea to disable the Views. It might be an idea to run an update and disable all Views that have broken handlers, and maybe just not allow Views that have broken handlers to be enabled. And when we hit the current 'broken' logic, we disable the View. Yes this is disruptive, but since it's almost impossible to judge the impact of a broken handler it would be the safe thing to do. Like the IS states, a broken filter could lead to an information disclosure (although unlikely, unless we break the node status filter), but best to be safe I think.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Pasqualle’s picture

As I rely on the functionality, that views with broken handlers still return a result, I would prefer this to be configurable.

I understand the broken filter handler might be a serious issue. But displaying a view with broken field handler is a useful feature on multisites (or sites using the same codebase), as the view works regardless if the field exists or not.

Pasqualle’s picture

Suggested solution: Do not display insecure views.
Views with
\Drupal\views\Plugin\views\relationship\Broken
\Drupal\views\Plugin\views\argument\Broken
\Drupal\views\Plugin\views\filter\Broken
should not return any results

Views with
\Drupal\views\Plugin\views\field\Broken
\Drupal\views\Plugin\views\sort\Broken
\Drupal\views\Plugin\views\area\Broken
should still return results.

For D10 display an error message instead of the result, for views with any broken handler. Allow to configure/override in contrib.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.