Errors when other modules incorrectly implement link_alter
mikeytown2 - October 14, 2008 - 20:46
| Project: | Statistics Advanced Settings |
| Version: | 6.x-1.4 |
| Component: | Miscellaneous |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | won't fix |
Jump to:
Description
Not sure if this is a Content Template or Statistics Advanced Settings problem but this is the white screen of death (WSOD) error I get when I go to use the create template link on a page with many CCK fields.
Fatal error: Cannot use object of type stdClass as array in .../sites/all/modules/statistics_advanced/statistics_advanced.module on line 111Disable Statistics Advanced Settings, and the problem goes away.
Version Info
Core 6.5
Statistics Advanced Settings 1.2
Contemplate 0.16
I got this error with the previous version of Contemplate, so this is nothing new as far as I know. It was fairly low on my priority list, since I have a workaround (disabling statistics advanced settings).

#1
I was encountering the same 'fatal error' with the same versions.
But I think that the question is misleading how many CCK fields the content type contains. I can reproduce the error message also with standard types without CCK fields, i.e. with "page", "blog", "image" and "poll", but not with "story" or "forum".
#2
my opinion is that it is the Statistics Advanced Settings advanced settings module, at least looking at the fatal error you are receiving that's what it looks like
#3
Thus I've created an appropriate issue at Statistics Advanced Settings (#321969: Fatal Error with Statistics Advanced Settings & ConTemplate) referring to this discussion here. However, I'm still not sure which of both modules needs to be reworked in order to be compatible to the other one.
#4
Cross-posting what I wrote in #321969: Fatal Error with Statistics Advanced Settings & ConTemplate:
I had this issue reported before and it's not the Statistics Advanced module at fault. See #318877: Cannot use object of type stdClass as array. Re-looking at that issue I'm guessing that they were also using Contemplate. To summarize that issue's findings:
What kind of variable is Contemplate providing for the links array?
#5
Looking into the code. From core's node.module:
<?php
function node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE) {
$node = (object)$node;
$node = node_build_content($node, $teaser, $page);
if ($links) {
$node->links = module_invoke_all('link', 'node', $node, $teaser);
drupal_alter('link', $node->links, $node);
}
?>
Latest contemplate:
<?php
function contemplate_node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE) {
$node = (object)$node;
$node = node_build_content($node, $teaser, $page);
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);
}
}
?>
I don't see any reason for this function not to follow core, and this may be the problem. There is additional checking done in drupal_alter.
#6
The proper way to remove the links from the node display you need to adjust the node template in node.tpl.php for the theme
#7
@jrglasgow: That's not true. We're talking about removing one of the node links, and not all of them. That's the whole purpose of the hook_link_alter. It's how core's translation module modifies/removes links:
<?phpfunction translation_translation_link_alter(&$links, $path) {
if ($paths = translation_path_get_translations($path)) {
foreach ($links as $langcode => $link) {
if (isset($paths[$langcode])) {
// Translation in a different node.
$links[$langcode]['href'] = $paths[$langcode];
}
else {
// No translation in this language, or no permission to view.
unset($links[$langcode]);
}
}
}
}
?>
And also core's forum module:
<?phpfunction forum_link_alter(&$links, $node) {
foreach ($links as $module => $link) {
if (strstr($module, 'taxonomy_term')) {
// Link back to the forum and not the taxonomy term page. We'll only
// do this if the taxonomy term in question belongs to forums.
$tid = str_replace('taxonomy/term/', '', $link['href']);
$vid = variable_get('forum_nav_vocabulary', '');
$term = taxonomy_get_term($tid);
if ($term->vid == $vid) {
$links[$module]['href'] = str_replace('taxonomy/term', 'forum', $link['href']);
}
}
}
}
?>
#8
I'll load up a working version of the Contemplate module tonight so I can test #6, but has anyone else tried replacing the contemplate_node_view code with the code from node_view yet to see if this fixes the issue?
#9
I'm not using Contemplate, but panels and I'm getting this.
#10
I don't use "Content Templates", but I did install the advanced statistics today - and the error popped up. Disabling the module cures the problem
#11
Ok moving back to Statistics Advanced. This is really frustrating since obviously some other module is messing up a completely valid hook implementation...
#12
I don't use "Content Templates" either and I'm having the same error with "Statistic's Advanced"
#13
I had this same problem. In my case, I was using the usercomment module and it had coded the link_alter call incorrectly (reversed the parms). See #337405: hook_link_alter call was incorrect for a patch to usercomment (for those of you using it).
#14
Had my hopes up, Chuck, until I realized that I'm not using that module. :/
I'm receiving this error as well, as soon as I flip Advanced Stats on... however, after some testing of flipping various modules off, I find that turning "Advanced Forum" off gets rid of the error and allows me to hit the (forum) node that was causing fits.
Has anyone looked at this adv forum module as a possible culprit? I'm not much of a php coder otherwise I'd dive in myself.
#15
Actually, I just took a look at advanced_forum.module and it looks like the same issue Chuck described above applies here as well.
Old:
foreach (module_implements('link_alter') as $module) {
$function = $module .'_link_alter';
$function($node, $links);
New:
foreach (module_implements('link_alter') as $module) {
$function = $module .'_link_alter';
$function($links, $node);
Making this change gets rid of the error. I also added a bug report to the Advanced Forum project to get this fixed up on that side.
#16
Thanks for all the detective work Apollo16 and chuckdeal97!
Keeping track of all the modules that need to be fixed:
Advanced Forum: #337457: Incorrect implementation of link_alter
User Comment: #337405: hook_link_alter call was incorrect
Forum Thread: #343486: Incorrect implementation of link_alter
Contemplate: #349970: Incorrect implementation of link_alter
Panels: #349979: Incorrect implementation of link_alter
#17
So I checked out EVERY contrib module from CVS today so I could search them. Here's the results for modules which probably contain the incorrect implementation:
./DRUPAL-6--4/ecommerce_plus/cart/cart.views.inc-43- $function = $module .'_link_alter';
./DRUPAL-6--4/ecommerce_plus/cart/cart.views.inc:44: $function($node, $links);
./DRUPAL-6--4/ecommerce_plus/cart/cart.views.inc-45- }
--
./DRUPAL-6--1/forumthread/forumthread.module-123- $function = $module .'_link_alter';
./DRUPAL-6--1/forumthread/forumthread.module:124: $function($node, $links);
./DRUPAL-6--1/forumthread/forumthread.module-125- }
--
./DRUPAL-6--1/usercomment/usercomment.module-363- $function = $module .'_link_alter';
./DRUPAL-6--1/usercomment/usercomment.module:364: $function($node, $links);
./DRUPAL-6--1/usercomment/usercomment.module-365- }
--
./HEAD/comment_og/comment.module.patched-967- $function = $module .'_link_alter';
./HEAD/comment_og/comment.module.patched:968: $function($node, $links);
./HEAD/comment_og/comment.module.patched-969- }
--
./HEAD/ecommerce_plus/cart/cart.views.inc-38- $function = $module .'_link_alter';
./HEAD/ecommerce_plus/cart/cart.views.inc:39: $function($node, $links);
./HEAD/ecommerce_plus/cart/cart.views.inc-40- }
--
./HEAD/leftandright/taxonomy.module-43- $function = $module .'_link_alter';
./HEAD/leftandright/taxonomy.module:44: $function($node, $links);
./HEAD/leftandright/taxonomy.module-45- }
--
./HEAD/localizer/taxonomy/taxonomy.module-43- $function = $module .'_link_alter';
./HEAD/localizer/taxonomy/taxonomy.module:44: $function($node, $links);
./HEAD/localizer/taxonomy/taxonomy.module-45- }
--
./HEAD/forumthread/forumthread.module-126- $function = $module .'_link_alter';
./HEAD/forumthread/forumthread.module:127: $function($node, $links);
./HEAD/forumthread/forumthread.module-128- }
--
./HEAD/advcache/all_patches.patch-129- $function = $module .'_link_alter';
./HEAD/advcache/all_patches.patch:130: $function($node, $links);
./HEAD/advcache/all_patches.patch-131- }
--
./HEAD/advcache/comment_cache.patch-39- $function = $module .'_link_alter';
./HEAD/advcache/comment_cache.patch:40: $function($node, $links);
./HEAD/advcache/comment_cache.patch-41- }
--
./HEAD/category/wrappers/taxonomy.module.copyme-47- $function = $module .'_link_alter';
./HEAD/category/wrappers/taxonomy.module.copyme:48: $function($node, $links);
./HEAD/category/wrappers/taxonomy.module.copyme-49- }
--
./HEAD/advanced_forum/advanced_forum.module-485- $function = $module .'_link_alter';
./HEAD/advanced_forum/advanced_forum.module:486: $function($node, $links);
./HEAD/advanced_forum/advanced_forum.module-487- }
--
./HEAD/usercomment/usercomment.module-363- $function = $module .'_link_alter';
./HEAD/usercomment/usercomment.module:364: $function($node, $links);
./HEAD/usercomment/usercomment.module-365- }
--
./HEAD/millennium/millennium.module-1741- $function = $module .'_link_alter';
./HEAD/millennium/millennium.module:1742: $function($node, $links);
./HEAD/millennium/millennium.module-1743- }
./DRUPAL-6--2/panels/content_types/node_content.inc-106- $function = $module .'_link_alter';
./DRUPAL-6--2/panels/content_types/node_content.inc:107: $function($node, $node->links);
./DRUPAL-6--2/panels/content_types/node_content.inc-108- }
--
./DRUPAL-6--2/panels/docs/sample_plugin_ct.inc-442- $function = $module .'_link_alter';
./DRUPAL-6--2/panels/docs/sample_plugin_ct.inc:443: $function($node, $node->links);
./DRUPAL-6--2/panels/docs/sample_plugin_ct.inc-444- }
--
./DRUPAL-6--1/contemplate/contemplate.module-810- $function = $module .'_link_alter';
./DRUPAL-6--1/contemplate/contemplate.module:811: $function($node, $node->links);
./DRUPAL-6--1/contemplate/contemplate.module-812- }
--
./DRUPAL-6--1/contemplate/contemplate-link-alter-D6.patch-15-- $function = $module .'_link_alter';
./DRUPAL-6--1/contemplate/contemplate-link-alter-D6.patch:16:- $function($node, $node->links);
./DRUPAL-6--1/contemplate/contemplate-link-alter-D6.patch-17-- }
--
./DRUPAL-6--3/panels/content_types/node_content.inc-106- $function = $module .'_link_alter';
./DRUPAL-6--3/panels/content_types/node_content.inc:107: $function($node, $node->links);
./DRUPAL-6--3/panels/content_types/node_content.inc-108- }
--
./DRUPAL-6--3/panels/docs/sample_plugin_ct.inc-442- $function = $module .'_link_alter';
./DRUPAL-6--3/panels/docs/sample_plugin_ct.inc:443: $function($node, $node->links);
./DRUPAL-6--3/panels/docs/sample_plugin_ct.inc-444- }
--
./HEAD/panels/content_types/node_content.inc-106- $function = $module .'_link_alter';
./HEAD/panels/content_types/node_content.inc:107: $function($node, $node->links);
./HEAD/panels/content_types/node_content.inc-108- }
--
./HEAD/panels/docs/sample_plugin_ct.inc-442- $function = $module .'_link_alter';
./HEAD/panels/docs/sample_plugin_ct.inc:443: $function($node, $node->links);
./HEAD/panels/docs/sample_plugin_ct.inc-444- }
--
./HEAD/active_template/template_api.module-694- $function = $module .'_link_alter';
./HEAD/active_template/template_api.module:695: $function($node, $node->links);
./HEAD/active_template/template_api.module-696- }
--
./HEAD/partial/partial.module-490- $function = $module .'_link_alter';
./HEAD/partial/partial.module:491: $function($node, $node->links);
./HEAD/partial/partial.module-492- }
--
./HEAD/contemplate/contemplate.module-550- $function = $module .'_link_alter';
./HEAD/contemplate/contemplate.module:551: $function($node, $node->links);
./HEAD/contemplate/contemplate.module-552- }
--
./HEAD/oaliquid/oaliquid.module-859- $function = $module .'_link_alter';
./HEAD/oaliquid/oaliquid.module:860: $function($node, $node->links);
./HEAD/oaliquid/oaliquid.module-861- }
--
./HEAD/node_scheduler/node_scheduler.module-474- $function = $module .'_link_alter';
./HEAD/node_scheduler/node_scheduler.module:475: $function($node, $node->links);
./HEAD/node_scheduler/node_scheduler.module-476- }
--
./HEAD/links_block/links_block.module-23- $function = $module .'_link_alter';
./HEAD/links_block/links_block.module:24: $function($node, $node->links);
./HEAD/links_block/links_block.module-25- }
#18
Marking this back as 'won't fix' and I'll keep updating my post #16 with the issues from other modules so we can track when they are fixed.
#19
+1
#20
I have this issue and also am not using contemplate, but am using xml sitemap and the Forums and Statistics that ship with 6.9 core. Thanks.
#21
@cgjohnson Are you using any other contrib modules? Any of the ones listed in #17?
#22
It told me to report, so I'm reporting.
Error message:
* Invalid parameters for hook_link_alter(). Please report this message to http://drupal.org/node/321295.
line 641 in /home/xxxxxx/public_html/sites/all/modules/contemplate/contemplate.module (contemplate_node_view)
line 668 in /home/xxxxxx/public_html/sites/all/modules/contemplate/contemplate.module (contemplate_node_views)
* Invalid parameters for hook_link_alter(). Please report this message to http://drupal.org/node/321295.
line 643 in /home/xxxxxx/public_html/sites/all/modules/contemplate/contemplate.module (contemplate_node_view)
line 668 in /home/xxxxxx/public_html/sites/all/modules/contemplate/contemplate.module (contemplate_node_views)
Using Content Templates (Contemplate) 6.x-1.0
#23
Me too, It told me to report below error, It was happening when I clicked on a content type to see their variables:
Invalid parameters for hook_link_alter(). Please report this message to http://drupal.org/node/321295.
line 641 in /home/thinghie/test/sites/all/modules/contemplate/contemplate.module (contemplate_node_view)
line 668 in /home/thinghie/test/sites/all/modules/contemplate/contemplate.module (contemplate_node_views)
Invalid parameters for hook_link_alter(). Please report this message to http://drupal.org/node/321295.
line 643 in /home/thinghie/test/sites/all/modules/contemplate/contemplate.module (contemplate_node_view)
line 668 in /home/thinghie/test/sites/all/modules/contemplate/contemplate.module (contemplate_node_views)
I am using
Drupal 6.10
contemplate-6.x-1.0
statistics_advanced-6.x-1.4
Nguyen Quoc Viet
#24
This worked for me...
$node->links['faq_view_comments_link'] = array(
'title' => t('View comments'),
'href' => "node/$node->nid",
'fragment' => 'comments',
'attributes' => array('title' => t('View comments')),
);
Takes me to:
id="comments"
Pathauto paths are maintained. (i.e. outputs /some-subcategory/some-page-title#comments rather than /node/55#comment).
#25
@angelopc @nguyenquocviet Contemplate's bug has been fixed in the 6.x-1.x-dev version. If you upgrade to that contemplate version the errors will go away.
#26
I found this problem on my website:
Invalid parameters for hook_link_alter(). Please report this message to http://drupal.org/node/321295.
line 65 in /home/beta/public_html/sites/all/modules/panels/content_types/node_content.inc (panels_admin_node_content)
line 229 in /home/beta/public_html/sites/all/modules/panels/includes/plugins.inc (panels_content_node_content)
I am using
Drupal 6.12
statistics_advanced-6.x-1.5
Panels 6.x-2.0-alpha3
I don't have contend template installed
#27
Thanks danielcala: I filed an issue with panels at #533770: Incorrect implementation of link_alter