Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
apadernoComment #2
apadernoFixed in 6.x-1.x-dev.