Fatal error: Cannot use object of type stdClass as array in /var/www/blahdeblah.com/sites/all/modules/statistics_advanced/statistics_advanced.module on line 111

...happens when trying to create template for content type File (module File Framework), via http://blahdebleh.com/admin/content/templates/file

Comments

dave reid’s picture

Project: Statistics Advanced » File Framework
Version: 6.x-1.2 » 6.x-1.x-dev

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

/**
 * 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

akwala, what version of file framework are you using? It looks like there may be some differences in checking array-types for $links between the 6.x-1.x-dev and 6.x-1.0-alpha2 versions. If the file framework module maintainer (miglius) thinks that the 6.x-1.x-dev version is safe for normal use, I'd probably recommend using that version.

miglius’s picture

The fileframework is still under heavy development, optimization, bug fixes. Dev version is much more mature than the alpha2. I'm trying to keep dev as stable as possible so I would recommend using it. But of course not everybody can use dev versions in the production.

akwala’s picture

Version: 6.x-1.x-dev » 6.x-1.0-alpha2

I'm using 6.x-1.0-alpha2 -- am also correcting it in the Version field of this issue.

--aslam

dave reid’s picture

akwala, are you using Contemplate?

miglius’s picture

Why do you think it is a FileFramework related issue? I have installed the Contemplate and Statistics Advanced Settings modules, enabled them, then went and successfully created a template for the file node, but didn't get the error you mentioned.

It does not matter that you're creating a file node template, but all modules which implement hook_link() can screw the $links variable. Since I don't know your setup, I can only recommend debug your system, i.e., trace all invocations of the hook_link() and the variable $links which is passed to all hooks and find which module changes the type from the array to the object.

dave reid’s picture

Hey, we're just trying to figure out where the problem is. If we need to bounce between several projects, that's no problem.

akwala’s picture

Yes, I am using Contemplate 6.x-0.16

--aslam

akwala’s picture

Should've probably checked this earlier...

This happens with the following content types:
- blog entry
- file
- forum topic
- book page
- page

It doesn't happen with the following content type:
- story

Those are all the content types I use. let me know if there is any particular difference between the 2 sets that I should look for.

--aslam

dave reid’s picture

Status: Active » Closed (duplicate)

This looks to be a problem with the Contemplate module and it's handling of node links. We're tracking that issue in #321295: Errors when other modules incorrectly implement link_alter. I'm going to mark this as a duplicate since we've narrowed down to the correct module.