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 111

Disable 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).

Comments

Garnerin’s picture

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".

jrglasgow’s picture

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

Garnerin’s picture

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.

dave reid’s picture

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:

The offending code is in my implementation of hook_link_alter which follows the specification completely:

Parameters
$links Nested array of links for the node
$node A node object for editing links on
/**
 * Implementation of hook_link_alter().
 *
 * Removes the node views counter for certain node types.
 */
110 function statistics_advanced_link_alter(&$links, $node) {
111   if (isset($links['statistics_counter'])) {
112     $counter_node_types = variable_get('statistics_advanced_counter_node_types', array_keys(node_get_types('names')));
113     if (!in_array($node->type, $counter_node_types)) {
114       unset($links['statistics_counter']);
115     }
116   }
117 }

Somehow, the $links parameter is being passed as an object, which is not the correct way to be using the hook. I don't see how the statistics_advanced module is in error here.

What kind of variable is Contemplate providing for the links array?

dave reid’s picture

Looking into the code. From core's node.module:

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:

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.

jrglasgow’s picture

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

dave reid’s picture

@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:

function 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:

function 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']);
      }
    }
  }
}
dave reid’s picture

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?

Flying Drupalist’s picture

I'm not using Contemplate, but panels and I'm getting this.

Ben Holmes’s picture

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

dave reid’s picture

Project: Content Templates (Contemplate) » Statistics Advanced
Version: 6.x-0.16 » 6.x-1.x-dev

Ok moving back to Statistics Advanced. This is really frustrating since obviously some other module is messing up a completely valid hook implementation...

marcus0263’s picture

I don't use "Content Templates" either and I'm having the same error with "Statistic's Advanced"

chuckdeal97’s picture

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).

Apollo610’s picture

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.

Apollo610’s picture

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.

dave reid’s picture

Status: Closed (won't fix) » Active

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

dave reid’s picture

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-          }
dave reid’s picture

Title: Contemplate & Statistics Advanced Settings error » Errors when other modules incorrectly implement link_alter
Component: Code » Miscellaneous
Status: Active » Closed (won't fix)

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.

lameei’s picture

Status: Active » Closed (won't fix)

+1

cgjohnson’s picture

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.

dave reid’s picture

@cgjohnson Are you using any other contrib modules? Any of the ones listed in #17?

angelopc’s picture

Version: 6.x-1.x-dev » 6.x-1.4

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

nguyenquocviet’s picture

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

i.chris.jacob’s picture

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).

dave reid’s picture

@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.

danielcala’s picture

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

dave reid’s picture

Thanks danielcala: I filed an issue with panels at #533770: Incorrect implementation of link_alter