pathauto_update_7005

  1. drupal
    1. 7 pathauto.install function
Drupal 7 pathauto_update_7005()

Fix original incorrect tokens in taxonomy and forum patterns.

File

sites/all/modules/pathauto/pathauto.install, line 146
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.';
}