Skip to content

Conversation

@rbargerhuff
Copy link
Contributor

  • Regex updated to make sure we're not evaluating a basic string/sentence wrapped in single quotes in order to prevent unnecessary warnings.
  • Regex now references the $raw_value variable that was preventing the warning from being written.

- Regex updated to make sure we're not evaluating a basic string/sentence wrapped in single quotes in order to prevent unnecessary warnings.
- Regex now references the $raw_value variable that was preventing the warning from being written.
@rbargerhuff
Copy link
Contributor Author

Fixes issue #56

@bugfolder
Copy link
Collaborator

Tested this.

Create a module, coder_upgrade_issue_56_test, containing this function:

function coder_upgrade_issue_56_test() {
  return variable_get('coder_upgrade_issue_56_var', t('Some text.'));
}

Pre-patch result:

Function converted to

function coder_upgrade_issue_56_test() {
  return config_get('coder_upgrade_issue_56.settings', 'coder_upgrade_issue_56_var');
}

Update hook implementation given as

function coder_upgrade_issue_56_update_1000() {
  $config = config('coder_upgrade_issue_56.settings');
  $config->set('coder_upgrade_issue_56_var', update_variable_get('coder_upgrade_issue_56_var', 't(' Some text . ')'));
  $config->save();

  update_variable_del('coder_upgrade_issue_56_var');
}

Which is incorrect.

Post-patch result:

Update hook implementation given as

function coder_upgrade_issue_56_update_1000() {
  $config = config('coder_upgrade_issue_56.settings');
  $config->set('coder_upgrade_issue_56_var', update_variable_get('coder_upgrade_issue_56_var', 'dynamic value in file /coder_upgrade_issue_56/coder_upgrade_issue_56.module line 13'));
  $config->save();

  update_variable_del('coder_upgrade_issue_56_var');
}

/**
 * Implements hook_install().
 */
function coder_upgrade_issue_56_install() {
  // Dynamically generated variable data was detected.
  // /coder_upgrade_issue_56/coder_upgrade_issue_56.module line 13
}

This is correct. A complex expression as the default value in variable_get() should result in the dynamic variable warning.

So looks ready to be committed.

@bugfolder bugfolder merged commit 9989a03 into backdrop-contrib:1.x-1.x May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants