Turn site hash into state instead of configuration

Created on 2 March 2018, almost 7 years ago
Updated 13 May 2024, 8 months ago

Currently the site hash is being generated when it is first requested and then saved into config. It is not a good practice to do unsolicited writes to the configuration (or even to the database in general). We have had some problems with this recently while preparing the update of a large distribution to Drupal 8.5.0:

  1. If the config is exported during initial development using a tool like config_devel β†’ after the module is installed, then the site_hash is stored as an empty string in the exported config. On initial deployment to production this works fine: a site hash is generated and subsequently used. If an update is deployed to the site, the site_hash becomes empty again, causing a new site hash to be generated, which differs from the original one.
  2. We don't allow configuration changes to be made on production, and are using config_readonly β†’ to enforce it. This caused exceptions to be thrown on our search pages, since the config was being altered.

I did some research and it seems this approach has originated many years ago in the original version of the ApacheSolr module in Drupal 5 (ref. apachesolr_site_hash()).

The solution is to generate the site hash when the module is installed, instead of on first use.

Note that it can be debated if this setting even belongs in config, or should be moved to state, but that is already being discussed in #2864967: Fix multisite search/multiple indexes on one core, tho it might break spell checking, autocomplete and suggesters β†’ . This issue is only about not writing config on an arbitrary GET request.

Marking this as a minor bug since it has limited impact for most websites.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡§πŸ‡¬Bulgaria pfrenssen Sofia

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024