Hook update readonlymode_update_8001 fails.

Created on 17 December 2020, almost 4 years ago
Updated 19 July 2024, 4 months ago

Problem/Motivation

Hook update fails due to missing function.

Steps to reproduce

Running updb - readonlymode_update_8001() produces an error.
- Call to undefined function update_variables_to_config()
I don't see this function defined anywhere.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

🇦🇺Australia shortradius

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 Kingdom altcom_neil

    Hi,

    I don't think what your initial patch does what the update hook was meant to be doing.

    I think it was intended to convert the 7.x version of the modules config to the 8.x version. It should be something like:

    function readonlymode_update_8001() {
      $settings = \Drupal::configFactory()->getEditable("readonlymode.settings");
      if (isset($settings['site_readonly'])) {
        // Config from the 7.x branch needs updating to 8.x structure.
        $new_settings = [
          'enabled' => $settings['site_readonly'],
          'url' => $settings['site_readonly_url'],
          'messages.default' => $settings['site_readonly_message'],
          'forms.additional.edit' => $settings['site_readonly_forms_allowed'],
          'forms.additional.view' => $settings['site_readonly_forms_viewonly'],
        ];
        $settings->setData($new_settings);
        $settings->save();
        return 'Updated readonlymode.settings configuration to 8.x version.';
      }
      return NULL;
    }
    

    I haven't tested this as we didn't use the 7.x version.

  • Status changed to Needs work 4 months ago
  • I think you're right. The changes are completely wrong. Can you update the MR?

Production build 0.71.5 2024