Deleting google plus config on install causes problems with site install and config split

Created on 7 July 2020, over 4 years ago
Updated 11 May 2023, over 1 year ago

Problem/Motivation

The social_media_update_8001 update hook causes errors when installing the site using acquia blt's `blt setup` and a config split. I get the following error:

The import failed due to the following reasons:
Deleted and replaced configuration "social_media.settings"

My understanding of what's happening is that blt is running drush site-install, which based on our configuration installs the module. After it's run site install, it imports default configuration, then it imports configuration from any enabled config split, at which point it fails. It looks like it's because the install hook set configuration that would have to be overwritten in order to import our settings. See core/lib/Drupal/Core/Config/ConfigImporter.php line 892 for more.

Proposed resolution

Only clear the google_plus settings if they exist. This prevents settings from being created on install if there are none existing and ensures there's nothing to overwrite when importing config later.

Remaining tasks

Review attached patch

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇺🇸United States jesse.d

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.

  • 🇺🇸United States luke.leber Pennsylvania

    Hey all,

    After reviewing this, I think the problem lies in the install hook -- not the update hook.

    /**
     * Remove google plus configuration.
     */
    function social_media_update_8001() {
      \Drupal::configFactory()->getEditable('social_media.settings')->clear('google_plus')->save();
    }
    
    /**
     * Implements hook_install().
     */
    function social_media_install() {
      social_media_update_8001();  <-- Let's just delete this line! 
    }
    

    We probably don't have to call the update hook from within the install hook because the module doesn't ship with default configuration for google plus anymore. In other words, new users installing the module won't have any google_plus config for us to delete :-). This should alleviate the BLT problem without needing to add any additional logic into the mix.

    If someone can re-roll this change against 2.0.x, I'd gladly review and merge it in.

    Cheers!

  • Assigned to bharath-kondeti
  • 🇮🇳India bharath-kondeti Hyderabad

    I will work on this patch reroll and provide the update.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update over 1 year ago
    1 pass
  • @bharath-kondeti opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update over 1 year ago
    1 pass
  • 🇮🇳India bharath-kondeti Hyderabad

    Addressed #3 and rerolled the patch for 2.0.x. Please review

Production build 0.71.5 2024