You are here

function pathauto_update_7005 in Pathauto 7

Fix original incorrect tokens in taxonomy and forum patterns.

File

./pathauto.install, line 203
Install, update, and uninstall functions for Pathauto.

Code

function pathauto_update_7005() {
  $replacements = array(
    '[vocabulary:name]' => '[term:vocabulary]',
    '[vocabulary:' => '[term:vocabulary:',
    '[term:catpath]' => '[term:name]',
    '[term:path]' => '[term:name]',
  );
  $variables = db_select('variable', 'v')
    ->fields('v', array(
    'name',
  ))
    ->condition(db_or()
    ->condition('name', db_like("pathauto_taxonomy_term_") . '%' . db_like('pattern'), 'LIKE')
    ->condition('name', db_like("pathauto_forum_") . '%' . db_like('pattern'), 'LIKE'))
    ->execute()
    ->fetchCol();
  foreach ($variables as $variable) {
    if ($pattern = variable_get($variable)) {
      $pattern = strtr($pattern, $replacements);
      variable_set($variable, $pattern);
    }
  }
  return 'Your Pathauto taxonomy and forum patterns have been corrected. You may wish to regenerate your taxonomy and forum term URL aliases.';
}