0

I tried to upgrade my site from Drupal 8 to Drupal 9. In this process I upgrade the module Permissions by Term to Version 3.0. The upgrade failed due to problems with extension of CiviCRM that were not covered by update report. So I turned back to D8. Afterwards I got the messages that the module Permissions by Term 3.0 was not compatible to D8 and thus disabled. So I downgraded that module by Composer successfully to version 2.31. After trying to reinstall it I got the error message that it couldn't be installed because of existing configuration. In the web I found several ways to delete old configurations, but of course I would like to keep it since I'm afraid I would have to review every page to set permissions again. Thus my questions: Is there any way to reinstall the module without deleting my old configurations (or was my fear wrong)?

2
  • Do you have any database backup from the time before the failed upgrade? If so, you should be able to get old configuration from there. Commented Mar 20, 2021 at 13:36
  • Thank you. Yes I do have a database backup. But it is a little old, since it took some time for me to realize the problem. So I don't just want to restore the old version of the database. What I thought, wouldn't it be a good idea just to try do reactivate the module in the database (of course after a new backup)? Since it has never been deinstalled just automatically deactivated, it might just work again. Could this be done in the config table?
    – paul77
    Commented Mar 20, 2021 at 18:52

2 Answers 2

0

Module configuration files are stored in the module's config/install directory. When you enable the module, Drupal tries to install those configurations. If Drupal complains that the configurations already exist, then you can take the following steps:

  1. Identify which configuration files Drupal is complaining about.

  2. Move those configuration files out the module's config/install directory. It doesn't really matter where you move them to, but you're going to want to restore the files after everything is fixed so I suggest just moving them up one level into the config directory.

  3. Try to install the module. Drupal won't find the module's default configuration files that you moved so it shouldn't complain any more.

  4. If Drupal still complains, that means you missed a configuration, so repeat the above steps.

  5. Restore the original configuration files - move them back into config/install.

Note that this is a workaround - not a solution. The module should be examined to ensure it properly removes its own configuration (if appropriate) when uninstalled, and that it declares the proper dependencies in its configuration, and that configurations which are not removed are defined as optional. Please file a bug report in the issue queue for that module so that this can be fixed for other users.

2
  • I'm not sure, if this is really a bug, since before downgrading to D9 I had forgotten to change the version of permissions_by_term in composer.json that I had manually set to ~3.0 , So if I remember correctly the message was that the module war disabled not deinstalled. Since I'm just a sitebuilder I'm not sure, what I could expect in a situation like that. If you still think I should file a bug report, I would do it.
    – paul77
    Commented Mar 20, 2021 at 20:59
  • In D7 you could disable a module, but in D8 and D9 there is no such thing as a "disabled" module - a module is either installed or not installed. I just now looked at the source code for that module and I think there is no bug in this case. The error seems to have happened because of the way you tried to downgrade the module (which isn't usually possible in Drupal ...). Normal install/uninstall of that module seems to be handled correctly by the module.
    – anonymous
    Commented Mar 20, 2021 at 21:30
0

For me I solved the problem by deleting the row permissions_by_term.settings in the table config (after I had realized that there were only a few settings I would be easily able to restore). Afterwards I could install the module. I did get an "unexpected error", but after refreshing the site, the module was marked as installed. But my site still missed the page for the module's settings. This changed after I had deinstalled the module and the reinstalled it again. In this process I lost the settings that had been stored in the tables permissions_by_term_role and permissions_by_term_user (that I could have saved, compare https://www.drupal.org/docs/contributed-modules/permissions-by-term), but since for me they were only few, it didn't matter. Thanks for your help.

1
  • Yes, removing the configuration from the database would work too, but I assumed from your question that you wanted to keep the previous settings. When you delete them from the database the module will install with its default settings - all the old settings will be lost. In my answer below, the old settings will be preserved.
    – anonymous
    Commented Mar 20, 2021 at 21:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.