You are here

function xmlsitemap_user_update_1 in XML sitemap 5

Implementation of hook_update_N(). Add missing URL aliases.

File

xmlsitemap_user/xmlsitemap_user.install, line 119

Code

function xmlsitemap_user_update_1() {
  $ret = array(
    update_sql("UPDATE {xmlsitemap_user} SET pid = NULL WHERE pid = 0"),
  );
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("\n        UPDATE {xmlsitemap_user} xu, {url_alias} ua SET xu.pid = ua.pid\n        WHERE xu.pid IS NULL AND ua.src = CONCAT('user/', CAST(xu.uid AS CHAR))\n      ");
      break;
    case 'pgsql':
      $ret[] = update_sql("\n        UPDATE {xmlsitemap_user} SET pid = {url_alias}.pid FROM {url_alias}\n        WHERE {xmlsitemap_user}.pid IS NULL AND {url_alias}.src = CONCAT('user/', CAST(uid AS VARCHAR))\n      ");
      break;
  }
  return $ret;
}