1. Detect variable_*() and reference the change record.
  2. Determine the module name by traversing up the directory structure and looking for the file with a .module extension.
    See below:
     // Search for a function named modulename_block_info in the .module file.   
        $filename_info = pathinfo($phpcsFile->getFilename());
        if ($filename_info['extension'] == 'module' && $tokens[$stackPtr]['type'] == 'T_FUNCTION' && $tokens[$stackPtr + 2]['content'] == $filename_info['filename'] . '_block_info') {
    
  3. Abstract this into a utility class. (Talk to Wim.)
  4. Replace:
    variable_get('mymodule_variable_name', 'foo');
    

    With:

    \Drupal::config('mymodule.setting')->get('variable_name');
    
  5. Create a default configuration file in mymodule/config/mymodule.settings.yml that sets the default for variable_name to 'foo' by saving as yaml (refer to info the info file conversion).
  6. Correct the variable change record to include an example of this.
  7. Add a comment line to the new configuration file that asks if variables should be moved to state: https://drupal.org/node/1175054
  8. Do similarly for variable_set().
  9. Do similarly for variable_delete(), except just remove it in a hook_uninstall().

Comments

gábor hojtsy’s picture

Committed http://drupalcode.org/sandbox/webchick/2193593.git/commitdiff/refs/heads... as a start. Also updated the change notice for variable_* to refer to the state API and the config API also.

xjm’s picture

Assigned: gábor hojtsy » eshta
xjm’s picture

Issue summary: View changes
eshta’s picture

Issue summary: View changes
webchick’s picture

Assigned: eshta » webchick

estha was STOLEN FROM US, so I'm taking this today. :)

webchick’s picture

Status: Active » Fixed

Ok, I'm going to call this fixed. YEAH.

Everything in the issue summary is done apart from #2195811: Remove variable_del() calls if they're in a hook_uninstall()., which I spun off a follow-up issue for.

webchick’s picture

Thanks so much for all of your help, eshta! :D

webchick’s picture

Project: Drupal 7 to 8 Module Upgrader [dead] » Drupal 7 to Modern Drupal Module Upgrader

Moving to new project.

Status: Fixed » Closed (fixed)

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

  • Commit 34b3b84 on master, moveallthethings, psr, console by Gábor Hojtsy:
    Issue #2193899: basics for variable_get, find them and report them as...
  • Commit 31d9502 on master, moveallthethings, console by webchick:
    Issue #2193899: HELL yes. Now it's writing the *correct* stuff to YAML...
  • Commit 99c2545 on master, moveallthethings, console by webchick:
    Issue #2193899: Fix quoting around variable names.
    
  • Commit e20ca2d on master, moveallthethings, console by webchick:
    Issue #2193899: Only return errors about variables once per variable.