Problem/Motivation
Currently, the module supports a single "lower environment" value that applies to all non-production environments (dev, stage, test, etc.). However,
different environments may need different values.
For example:
- Staging might need to point to
https://api-staging.example.com - Development might need to point to
https://api-dev.example.com - Local might need to point to
http://localhost:8000
Users currently have to maintain separate trackers or manually update values when syncing to different environments, which is error-prone and
time-consuming.
Steps to reproduce
- Create a field value tracker with a lower environment value
- Sync database to staging environment and run
drush fvt:update - Sync database to dev environment and run
drush fvt:update - Notice both environments receive the same value, when they may need different values
Proposed resolution
Add support for environment-specific values while maintaining backward compatibility:
- Configurable environments - Add simple YAML config (
field_value_tracker.environments.yml) listing available environments
with labels and descriptions - Environment-specific values field - Add
environment_valuesmap field to store per-environment values - Enhanced Drush command - Add
--envflag to specify which environment to use:
drush fvt:update --env=stage drush fvt:update --env=dev drush fvt:update # Uses default "all" value
- Smart fallback logic - If no environment-specific value exists for the specified environment, fall back to the default
lower_env_value - Backward compatibility - Existing trackers continue to work unchanged;
lower_env_valuebecomes the "all environments"
default - Update hook - Provide update hook to install new configuration and add new field
Remaining tasks
- ✅ Create config schema for environments
- ✅ Create default environments config YAML
- ✅ Add environment_values field to entity
- ✅ Update form with environment-specific value fields using proper DI
- ✅ Add --env flag to Drush command
- ✅ Update Drush command logic for environment-specific values
- ✅ Create update hook for migration
- ✅ Add comprehensive tests
- ⬜ Code review
- ⬜ Manual testing on real environments
- ⬜ Update documentation (README)
User interface changes
The tracker edit form at /admin/config/development/field-value-tracker/{id}/edit will show:
- Lower Environment Value - Relabeled as "All Environments (Default)" with description explaining it's used as the fallback
- Environment-specific Values - New collapsible details section containing:
- Dynamic textarea fields for each configured environment (stage, dev, etc.)
- Each field labeled with the environment's human-readable label
- Optional - leave empty to use the default "all" value
Screenshot: (Will be added after manual testing)
API changes
New field on field_value_tracker entity:
environment_values- Map field storing environment ID => value pairs
Updated Drush command:
field-value-tracker:update(alias:fvt:update)- New option:
--env=ENVIRONMENT- Specify target environment - Backward compatible - running without
--envuses default value
- New option:
New configuration:
field_value_tracker.environments- Simple config listing available environments
Data model changes
field_value_tracker entity:
- New field:
environment_values- Type:
map - Required: No
- Stores: Array of environment_id => value mappings
- Type:
- Existing field:
lower_env_value- Behavior change: Now serves as "all environments" default
- Still required
- Backward compatible
New configuration object:
field_value_tracker.environments.yml- Structure: Keyed array of environment definitions
- Each environment has:
labelanddescription - Ships with:
all,stage,dev - User-customizable via config management
Update hook:
field_value_tracker_update_11001()- Installs new config and addsenvironment_valuesfield to existing entities
Issue fork field_value_tracker-3554282
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 #2
jhedstrom