Download & Extend

Incorrect implementation of link_alter

Project:Content Templates (Contemplate)
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

I keep having problems with users reporting conflicts with Contemplate and my implementation of hook_link_alter in Statistics Advanced. I looked through the latest 6.x-1.x code for Contemplate again today and confirmed that it is incorrect. You can clearly see from the current D6 documentation for node_view and hook_link_alter that parameter order should be $links, then $node. This is different from the D5 implentation which is the reverse ($node, then $links). However, currently Contemplate passes $node, then $links.

Current code in 6.x-1.x contemplate.module:

<?php
function contemplate_node_view()
  ...
  if (
$links) {
   
$node->links = module_invoke_all('link', 'node', $node, !$page);

    foreach (
module_implements('link_alter') AS $module) {
     
$function = $module .'_link_alter';
     
$function($node, $node->links);
    }
  }
  ...
?>

And it should be:

<?php
function contemplate_node_view()
  ...
  if (
$links) {
   
$node->links = module_invoke_all('link', 'node', $node, !$page);
   
drupal_alter('link', $node->links, $node);
  }
  ...
?>

Attached patch against current 6.x-1.x that fixes the parameter order and uses drupal_alter, which is the preferred implementation in core (see the link to node_view above).

AttachmentSize
contemplate-link-alter-D6.patch824 bytes

Comments

#1

Status:needs review» fixed

Committed, thx ;)

#2

Thanks very much eMPee584!

#3

Status:fixed» closed (fixed)

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

nobody click here