You are here

function xmlsitemap_node_update_3 in XML sitemap 5

Implementation of hook_update_N(). Add missing URL aliases. Update last-changed times.

File

xmlsitemap_node/xmlsitemap_node.install, line 224

Code

function xmlsitemap_node_update_3() {
  $ret = array(
    update_sql("UPDATE {xmlsitemap_node} SET pid = NULL WHERE pid = 0"),
  );
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("\n        UPDATE {xmlsitemap_node} xn\n        INNER JOIN {node} n ON n.nid = xn.nid\n        LEFT JOIN {url_alias} ua ON ua.src = CONCAT('node/', CAST(xn.nid AS CHAR)) AND xn.pid IS NULL\n        SET xn.last_changed = n.changed, xn.pid = ua.pid\n      ");
      break;
    case 'pgsql':
      $ret[] = update_sql("\n        UPDATE {xmlsitemap_node}\n        SET pid = {url_alias}.pid, last_changed = {node}.changed\n        FROM {node} LEFT JOIN {url_alias} ON {url_alias}.src = CONCAT('node/', CAST({xmlsitemap_node}.nid AS VARCHAR)) AND {xmlsitemap_node}.pid IS NULL\n        WHERE {xmlsitemap_node}.nid = {node}.nid\n      ");
      break;
  }
  $ret = array_merge($ret, xmlsitemap_node_update_2());
  return $ret;
}