Fix compilation with minimal options enabled.
Some headers are being included but are not needed; they introduce false dependencies on optional components.
Also, the template editor links to the polygon session in order to demonstrate filters based on model-entity type; make that a hard dependency on the polygon session being enabled.
Backport: release