Problem/Motivation
While working on #2976147: Create a sales report supporting daily, weekly, monthly, and yearly breakdowns., my tests failed due to configuration schema validation.
Schema errors for views.view.sales_report with the following errors: views.view.sales_report:display.default.display_options.fields.report_id.set_precision missing schema
The report_id
is the entity identifier base field. The View has aggregation enabled, and the report_id
is set to COUNT.
In Views, the handler is swapped to numeric as an override when the display is built. This is causing a SchemaIncompleteException exception to be thrown.
This following code is what changes the handler and causes the schema error
\Drupal\views\Plugin\views\display\DisplayPluginBase::getHandlers
// If aggregation is on, the group type might override the actual
// handler that is in use. This piece of code checks that and,
// if necessary, sets the override handler.
$override = NULL;
if ($this->useGroupBy() && !empty($info['group_type'])) {
if (empty($this->view->query)) {
$this->view->initQuery();
}
$aggregate = $this->view->query->getAggregationInfo();
if (!empty($aggregate[$info['group_type']]['handler'][$type])) {
$override = $aggregate[$info['group_type']]['handler'][$type];
}
}
Steps to reproduce
Create test view, showing content of any type. Enable aggregation. Add field 'Content: ID' and set COUNT type of aggregation on added field.
Proposed resolution
Update logic of manipulating on 'plugin_id' option and change corresponding code, so plugin_id reflects actual state of the field.
Remaining tasks
Review patch/MR, give feedback, rework, accept.