You are here

function xmlsitemap_term_update_1 in XML sitemap 5

Implementation of hook_update_N(). Add missing URL aliases.

File

xmlsitemap_term/xmlsitemap_term.install, line 110

Code

function xmlsitemap_term_update_1() {
  $ret = array(
    update_sql("UPDATE {xmlsitemap_term} SET pid = NULL WHERE pid = 0"),
  );
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("\n        UPDATE {xmlsitemap_term} xt, {url_alias} ua SET xt.pid = ua.pid\n        WHERE xt.pid IS NULL AND (\n          ua.src = CONCAT('taxonomy/term/', CAST(xt.tid AS CHAR))\n          OR ua.src = CONCAT('forum/', CAST(xt.tid AS CHAR))\n        )\n      ");
      break;
    case 'pgsql':
      $ret[] = update_sql("\n        UPDATE {xmlsitemap_term} SET pid = {url_alias}.pid FROM {url_alias}\n        WHERE {xmlsitemap_term}.pid IS NULL AND (\n          {url_alias}.src = CONCAT('taxonomy/term/', CAST(tid AS VARCHAR))\n          OR {url_alias}.src = CONCAT('forum/', CAST(tid AS VARCHAR))\n        )\n      ");
      break;
  }
  return $ret;
}