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

Thx for your work

#1

Grayside - October 12, 2009 - 18:19

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

Amitaibu - October 15, 2009 - 08:23
Priority:normal» critical
Status:active» needs review

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

AttachmentSize
596564-use-flag-enable-1.patch 2.17 KB

#3

quicksketch - October 15, 2009 - 16:05

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

Amitaibu - October 15, 2009 - 16:12

+++ 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

quicksketch - October 15, 2009 - 18:34

We won't create another flag, as we have this check.

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

Amitaibu - October 15, 2009 - 18:53
Status:needs review» needs work

sounds ok. I'm without dev enviroment (it's the weekend after all) so I won't get to it untill next week.

#7

Amitaibu - October 19, 2009 - 08:12
Status:needs work» needs review

Patch uses flag_get_flags().

AttachmentSize
596564-use-flag-enable-7.patch 2.35 KB

#8

quicksketch - October 26, 2009 - 21:30
Status:needs review» fixed

Committed. Thanks again Amitaibu!

#9

System Message - November 9, 2009 - 21:40
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.