hook_uninstall() does the wrong thing with config settings

Created on 7 July 2023, 12 months ago
Updated 10 July 2023, 12 months ago

In #2936338: Unable to install Honeypot, honeypot.settings already exists in active configuration. , code was added to hook_uninstall() in order to try to delete the Honeypot config settings. Specifically, this line was added:
\Drupal::configFactory()->getEditable('honeypot.settings.yml')->delete();

There are two problems with this:

1) In D8+, config settings are automatically installed when a module is installed and automatically deleted by the config system when a module is uninstalled. In D7, by contrast, system variables used by a module with variable_get()/variable_set() needed to be explicitly deleted on uninstall - because of this many people have the misconception that you have to do the same thing for configuration settings, but that is not so.

2) The added code deletes the configuration "honeypot.settings.yml" - but there IS NO SUCH configuration. The only configuration defined is "honeypot.settings". Because there is no such configuration, this line has never done anything in the past and is therefore it is perfectly safe to remove this line.

🐛 Bug report
Status

Fixed

Version

2.1

Component

Code

Created by

🇺🇸United States TR Cascadia

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

Comments & Activities

Production build 0.69.0 2024