Posted by akwala on October 9, 2008 at 4:43am
3 followers
Jump to:
| Project: | File Framework |
| Version: | 6.x-1.0-alpha2 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (duplicate) |
Issue Summary
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
#1
The offending code is in my implementation of hook_link_alter which follows the specification completely:
<?php/**
* 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...
#2
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.
#3
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.
#4
I'm using 6.x-1.0-alpha2 -- am also correcting it in the Version field of this issue.
--aslam
#5
akwala, are you using Contemplate?
#6
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.
#7
Hey, we're just trying to figure out where the problem is. If we need to bounce between several projects, that's no problem.
#8
Yes, I am using Contemplate 6.x-0.16
--aslam
#9
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
#10
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.