"Unsupported operand" error installing flag module
srobert72 - October 5, 2009 - 19:12
| Project: | Flag |
| Version: | 6.x-2.x-dev |
| Component: | Flag core |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed |
Description
Here is my error message when enabling flag module :
Fatal error: Unsupported operand types in /home/drupal/drupal/sites/all/modules/flag/flag.inc on line 950Thx for your work

#1
I found this problem under PHP 5.3 with Zen interacting with the core url() function. In that case, moving the first array element to the same line as the array declaration seemed to fix it.
In other words,
function get_views_info() {return array(
'views table' => 'node',
Becomes
function get_views_info() {return array( 'views table' => 'node',
#2
The problem was that we tried to create a flag on hook_install, but flag's hook implementation were not used as module wasn't considred enabled.
Patch moves the flag creation to hook_enable().
#3
I don't think using hook_enable() is a good way of handling this, as it will cause Flag to re-create a bookmark flag every time the module is enabled. Or worse yet, this would actually *overwrite* existing settings that a user had made to the bookmark flag.
Amitaibu, could you clarify what you mean by "flag's hook implementation were not used"? Does Flag need to have some hooks firing during install?
#4
+++ flag.install 15 Oct 2009 08:22:13 -0000@@ -7,24 +7,17 @@
+ if (!flag_get_flag('bookmarks')) {
We won't create another flag, as we have this check.
> Does Flag need to have some hooks firing during install?
Yes - The problem is that module_invoke_all('flag_link_types') doesn't find flag_flag_link_types().
This review is powered by Dreditor.
#5
Ah, but the problem still exists if the user deleted that flag, it will be re-created by enabling/disabling the module. :-/ Let's use a count(flag_get_flags()) instead, so that if there are *any* flags, we won't recreate the bookmarks flag.
#6
sounds ok. I'm without dev enviroment (it's the weekend after all) so I won't get to it untill next week.
#7
Patch uses flag_get_flags().
#8
Committed. Thanks again Amitaibu!
#9
Automatically closed -- issue fixed for 2 weeks with no activity.