Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
With each new version of farmOS, there may be changes to configuration that need to be reverted/applied between updates.
As I see it, there are two potential host/administrator workflows in this regard:
- farmOS instances that are "default configurations" which always want to have the most up-to-date config. (Farmier hosting is basically this... but a lot of self-hosted instances will also want this to be automatic.)
- farmOS instances that are more customized, where some config may be overridden, and the instance administrator wants to manually review and apply config changes themselves.
Proposed resolution
I propose that we add a core farm_update
module, that can be optionally enabled. When enabled, it will automatically maintain configuration so that it is always in sync with the modules that provide it. This will cover the first use case (fully automated configuration updates).
If this is not desired (second use case), then the module can simply be disabled.
Remaining tasks
TBD
User interface changes
TBD
API changes
TBD
Data model changes
TBD
Comments
Comment #2
m.stentaBig questions here are:
1. How do we know what config to maintain?
2. How/when/where do we maintain it?
Comment #3
m.stenta> How do we know what config to maintain?
@pcambra pointed to the config_devel module as a possible example to learn from. They use a concept of "third party settings" in module info.yml files to define all the config that is "owned" by a module.
If we implemented something similar, we could essentially make a list of all the config items that each module manages, and the
farm_update
module could read that and only act on those config items.Or, maybe that's not even necessary, maybe
farm_update
can auto-detect the config by looking at theconfig/install
andconfig/optional
directories directly.Comment #4
m.stenta> How/when/where do we maintain it?
The whole point of having this is so that we don't need to add endless
hook_update_N()
implementations for minor config changes. Buthook_update_N()
IS the easiest way to ensure this logic runs on updates, I think.Alternatively, I wonder if
hook_cache_flush()
would work? Does that run every time thatupdate.php
is run? If so, then all we have to do is tell users to runupdate.php
and it will update the config. But... I'm not sure if caches get cleared byupdate.php
if there aren't any actualhook_update_N()
implementations to run...Comment #5
m.stentaThis related upstream issue in the
config_rewrite
module might be worth dusting off... IIRC it prevents "rewritten" config from showing as "overridden" in the configuration updates report.I'm not sure if that would help with this issue at all... but if we need to be able to compare against "rewritten" config then maybe that provides some insight.
Comment #6
m.stentaI think this would make
farm_update
a dependency of all modules that include these settings, which would defeat the purpose of being able to disable it.A hook is a simple approach that would keep this optional, and would allow modules to define config that they don't want to be updated. A similar approach can be taken with a simple config for the update module itself.
hook_rebuild()
is another option (runs after caches are flushed): https://api.drupal.org/api/drupal/core!core.api.php/function/hook_rebuil...Still an open question as to whether or not this runs via
update.php
even when there are no new update hooks. We could provide a Drush command to manually run the revert logic too.We decided to remove
config_rewrite
from farmOS, so this is no longer relevant.Comment #7
m.stentaOpened a pull request for review: https://github.com/farmOS/farmOS/pull/444
Comment #8
m.stentaThis is causing
farm_api
tests to fail for some reason... commenting outfarm_update
in the base modules list infarm.profile
fixes it. Needs more investigation...Comment #9
m.stentaAh the tests are revealing some more config that needs to be excluded:
user.role.anonymous
user.role.authenticated
These were being overridden during the
TokenBearerFunctionalTestBase
. And in general we should not be reverting these two roles ever.I also excluded
system.performance
.Tests are passing now.
Comment #11
m.stentaMerged.
There was some additional discussion in the pull request regarding triggering this via update.php, but I opted to just add instructions for clearing the cache after updating farmOS for now: https://github.com/farmOS/farmOS/pull/444