Hi,

In the hook_query_xmlsitemap_generate_alter example there are references to the deprecated db_and and db_or functions. These should be replaced with the andConditionGroup and orConditionGroup functions.

/**
 * Alter the query selecting data from {xmlsitemap} during sitemap generation.
 *
 * @param $query
 *   A Query object describing the composite parts of a SQL query.
 *
 * @see hook_query_TAG_alter()
 */
function hook_query_xmlsitemap_generate_alter(QueryAlterableInterface $query) {
  $sitemap = $query->getMetaData('sitemap');
  if (!empty($sitemap->context['vocabulary'])) {
    $node_condition = db_and();
    $node_condition->condition('type', 'taxonomy_term');
    $node_condition->condition('subtype', $sitemap->context['vocabulary']);
    $normal_condition = db_and();
    $normal_condition->condition('type', 'taxonomy_term', '<>');
    $condition = db_or();
    $condition->condition($node_condition);
    $condition->condition($normal_condition);
    $query->condition($condition);
  }
}

Cheers

Tom

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

blacklabel_tom created an issue. See original summary.

blacklabel_tom’s picture

blacklabel_tom’s picture

Status: Active » Needs review
rivimey’s picture

Status: Needs review » Reviewed & tested by the community
alex_optim’s picture

Looks good.

pifagor’s picture

pifagor’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.