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

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

shortradius created an issue. See original summary.

shortradius’s picture

Issue summary: View changes

Gonzalo2683 made their first commit to this issue’s fork.

solideogloria’s picture

Version: 8.x-1.1 » 8.x-1.x-dev
Status: Active » Needs review
altcom_neil’s picture

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.

solideogloria’s picture

Status: Needs review » Needs work

I think you're right. The changes are completely wrong. Can you update the MR?

Also, I would use $config instead of $settings

astonvictor made their first commit to this issue’s fork.

astonvictor’s picture

Status: Needs work » Needs review

Actually, there is no need to use the update function anymore.
The update_variables_to_config() function was created to move variables to configs from Drupal 7 to Drupal 8. Currently, all releases only work with Drupal 10+. So, it doesn't make sense.

I think we should keep the empty function in case someone adds a new update function that should end with +1 in the name.

astonvictor’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.