Move metadata_last_time from Config API to State API

Created on 1 February 2024, 10 months ago

Problem/Motivation

The configuration system is meant for deployment across environments, and storing dynamic values like timestamps in it is not ideal.

Steps to reproduce

Configure the module and export config. Import in another environment and observe the last import time is incorrect

Proposed resolution

The State API is designed for storing local, stateful information, such as temporary data and operational aspects like the last time an import was performed. This data is specific to an environment and is not meant to be exported with configuration synchronization.

Overview of tasks:

Migrate Storage Method:

  • Replace usage of the Config API with the State API for metadata_last_time.
  • In GoogleAnalyticsReports.php, change saving of metadata_last_time to use \Drupal::state()->set() instead of the Config API.
  • In GoogleAnalyticsReportsAdminSettingsForm.php, change retrieval of metadata_last_time to use \Drupal::state()->get().

Remove Schema Definition:

  • Remove the metadata_last_time definition from google_analytics_reports.schema.yml, as it will no longer be part of the module's configuration.

Update Default Configuration:

  • Remove metadata_last_time: '' from google_analytics_reports.settings.yml under config/install, since the value will now be managed via the State API.

Implement a hook_update_N Function:

  • Write an update hook (hook_update_N()) to migrate existing metadata_last_time values from config to state for existing installations

Remaining tasks

  • ✅ File an issue
  • ✅ Addition/Change/Update/Fix
  • ✅ Testing to ensure no regression
  • ➖ Automated unit testing coverage
  • ➖ Automated functional testing coverage
  • N/A UX/UI designer responsibilities
  • ✅ Readability
  • ✅ Accessibility
  • ✅ Performance
  • ✅ Security
  • N/A Documentation
  • ➖ Code review by maintainers
  • ➖ Full testing and approval
  • ➖ Credit contributors
  • ➖ Review with the product owner
  • ➖ Release notes snippet
  • ❌ Release

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

  • N/A
🐛 Bug report
Status

Needs review

Version

4.0

Component

Reports module

Created by

🇺🇸United States scottatdrake

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024