xmlsitemap_node_priority() uses the variable $node->priority_override without to check if it is set.
Actually it checks that, but after it used its value.

The following code could then be changed from:

  if (!isset($node->priority_override)) {
    $priority = 0;
    $priority += variable_get("xmlsitemap_node_type_priority_$node->type", 0.5);
    // ...
  }

to:

  if (!isset($node->priority_override)) {
    $priority = variable_get("xmlsitemap_node_type_priority_$node->type", 0.5);
    // ...
  }

I would change the full function into:

function xmlsitemap_node_priority($node) {
  static $promote_priority;
  static $comment_priority;
  static $maxcomments;
  $promote_priority = isset($promote_priority) ? $promote_priority : variable_get('xmlsitemap_node_promote_priority', 0.3);
  $comment_priority = isset($comment_priority) ? $comment_priority : variable_get('xmlsitemap_node_comment_priority', 0.5);
  if (!isset($maxcomments)) {
    $maxcomments = 0;
    if (module_exists('comment')) {
      $maxcomments = db_result(db_query("SELECT MAX(comment_count) FROM {node_comment_statistics}"));
    }
  }
  if (isset($node->priority_override)) {
    $priority = $node->priority_override;
  }
  else {
    $priority = variable_get("xmlsitemap_node_type_priority_$node->type", 0.5);
    if ($node->promote) {
      $priority += $promote_priority;
    }
    if (!empty($maxcomments)) {
      $priority += $node->comment_count / $maxcomments * $comment_priority;
    }
    $priority = round($priority, 1);
    $priority = min($priority, 0.9);
  }
  return $priority;
}

Comments

apaderno’s picture

Title: xmlsitemap_node_priority() uses an object variable without to check if it is set » xmlsitemap_node_priority() uses a variable without to check if it is set
apaderno’s picture

Version: 7.x-2.x-dev » 6.x-1.x-dev
Assigned: Unassigned » apaderno
Status: Active » Fixed

Fixed in 6.x-1.x-dev.

Status: Fixed » Closed (fixed)

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