Problem/Motivation
The Views field plugin geofield_proximity_field defines three options in GeofieldProximityField::defineOptions(): units, source and source_configuration. Its config schema, views.field.geofield_proximity_field, extends views.field.numeric and adds none of them.
So any view that uses the proximity field fails strict config schema validation. Every kernel test in a module that ships such a view hits this, because KernelTestBase checks schema strictly by default. Config Inspector reports the same errors, and the values are saved without type casting.
The proximity sort, views.sort.geofield_proximity_sort, and the proximity filter, views.filter.geofield_proximity_filter, already declare these keys. The field plugin is the one that was missed.
Present on 8.x-1.67 and on 10.3.x at 41e839fe.
Steps to reproduce
- Create a view of an entity with a Geofield, and add the "Geofield Proximity Field" field.
- Export the view and install it from a module's
config/installorconfig/optionalin a kernel test, or inspect it with Config Inspector. - Schema validation fails with:
views.view.example:display.default.display_options.fields.field_geo_proximity.units missing schema views.view.example:display.default.display_options.fields.field_geo_proximity.source missing schema views.view.example:display.default.display_options.fields.field_geo_proximity.source_configuration missing schema
Proposed resolution
Declare the three options on the field plugin's schema, matching what the proximity filter's schema already declares for source_configuration. The keys below are the ones the four shipped source plugins store: ManualOriginDefault, ClientLocationOriginFilter, OriginFromProximityFilter and ContextProximityFilter.
views.field.geofield_proximity_field: type: views.field.numeric label: 'Geofield Proximity Field' mapping: units: type: string label: 'Units' source: type: string label: 'Origin source plugin' source_configuration: type: mapping label: 'Origin source configuration' mapping: origin: type: mapping mapping: lat: type: string lon: type: string origin_hidden_flag: type: boolean origin_summary_flag: type: boolean source_proximity_filter: type: string
The sort's source_configuration declares only source_proximity_filter. It could use the same mapping, since a sort can also take the manual origin. A shared type definition would keep the field, sort and filter from drifting apart again.
Remaining tasks
Add the schema.Add a kernel test that installs a view using the proximity field with strict schema checking on.
User interface changes
None.
API changes
None.
Data model changes
None. Saved views keep the same keys; only their schema is declared.
Issue fork geofield-3626818
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
tbcs commentedMR adds the missing schema for the proximity field's
units,sourceandsource_configuration. The origin source settings are now a shared type,geofield_proximity_source_configuration, used by the proximity field, filter and sort. The sort's mapping had only coveredsource_proximity_filter, so it failed with the manual origin too.ProximityViewsSchemaTestsaves a view using all three; it fails on 10.3.x without the change.Comment #4
tbcs commentedComment #5
tbcs commented