Add an isComputed method to field handlers

Created on 3 October 2014, about 10 years ago
Updated 29 August 2024, 3 months ago

Problem/Motivation

All field handlers that provide things like links do not want to do anything to affect the views query. So the current 'API' for this is just overriding the query() method and leaving it empty, so the parent does not get called. It would be nicer to make this explicit, like click sort is declared.

Additionally, other Views plugins need to be able to determine whether or not a field handler influences the query, since those plugins might rely on the fact that the field handler adds one or more fields to the query. See #2401953: Database exception for View with Combined field filter with fields with no query alias β†’ for an example of this scenario.

Task because computed fields always existed, at least on a implicit level.

Proposed resolution

Add an isComputed() method to FieldPluginBase, this would default to false. Handlers could then either add 'computed' to the views data implementation using the handler or just overriding the method. The base query method can then check this property.

Remaining tasks

- Address issue comments by updating issue summary about why issue is in Needs work status and add these to Remaining tasks.
- Add a merge request for 11.x branch so that tests run and test-only job can run.

User interface changes

?

API changes

?

πŸ“Œ Task
Status

Needs work

Version

11.0 πŸ”₯

Component
ViewsΒ  β†’

Last updated about 4 hours ago

Created by

πŸ‡¬πŸ‡§United Kingdom damiankloip

Live updates comments and jobs are added and updated live.
  • VDC

    Related to the Views in Drupal Core initiative.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024