Me and mikeytown2, we encountered a 'fatal error' with Content Templates referring to Statistics Advanced Settings. We both are not sure where to place this issue, mikeytown2 tried with Contemplate, jrglasgow (co-maintainer of Contemplate) supposes the issue belongs to Statistics Advanced Settings. What do you think?

Please take a look at the discussion over there: #321295: Errors when other modules incorrectly implement link_alter

Comments

dave reid’s picture

Status: Active » Closed (won't fix)

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. 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. I'm passing this issue to the file framework project and I'll see if I can find somewhere in this massive code where it's going wrong...

dave reid’s picture

I'm going to guess if you disabled the Statistics Advanced module and enabled the core Translation module, you'd also get the same error. That core module does nearly the same kind of thing mine does:

http://api.drupal.org/api/function/translation_translation_link_alter/6

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]);
      }
    }
  }
}
kingofsevens’s picture

Version: 6.x-1.2 » 6.x-1.3

Fatal error: Cannot use object of type stdClass as array in /home/asistanb/public_html/yeni/sites/all/modules/statistics_advanced/statistics_advanced.module on line 47

Received this error code when clicked on create template for the node. Just giving a nudge to the issue.

dave reid’s picture

Status: Closed (won't fix) » Closed (duplicate)

This is officially a duplicate of #321295: Errors when other modules incorrectly implement link_alter, but still not something I can fix. Please check out the list of modules that have incorrect code that causes the error in http://drupal.org/node/321295#comment-1120041. If you use one of the modules, please update it to the latest version.