Hi!
I`m added Action "Modify user roles" and active this action in Quiz node. If test completed I have error:
Fatal error: Unsupported operand types in *.ru/sites/all/modules/views_bulk_operations/user_roles.action.inc on line 62

How I can solve this problem?

CommentFileSizeAuthor
#4 822202.patch680 bytesinfojunkie
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

GameCharmer’s picture

Same issue persists with current version on line 69. Issue still persists on dev version at line#61.
Previous post in the quiz module issues queue: http://drupal.org/node/1083346

infojunkie’s picture

I don't understand the context. "Modify user roles" applies to users, not nodes. What's the connection to Quiz module? Can you reproduce this in the context of normal page nodes?

GameCharmer’s picture

When a user completes a quiz and passes, the quiz module calls the action "Assign User to X Role", where X is a custom role I set up to allow users to post content. Basically, you can register but not post content unless you can pass a test, which is more or less just a basic "Do you understand not to do this and that" kinda thing.

I'm trying to fire an action on completion, but it is crashing out on me.

I updated to the latest revisions and still got the issue. I then upgraded to the dev versions and I get the same issue, just a different line number.

Fatal error: Unsupported operand types in /home/gcworld/public_html/sites/all/modules/views_bulk_operations/user_roles.action.inc on line 70

infojunkie’s picture

Version: 6.x-1.9 » 6.x-1.x-dev
Status: Active » Needs review
FileSize
680 bytes

Please try the attached patch. Does this work fix it?

GameCharmer’s picture

Version: 6.x-1.x-dev » 6.x-1.9
Status: Needs review » Active

That eliminated the error message, but the role still isn't being assigned. That patch shouldn't be necessary as it's listing roles to add, and if there are no roles to add, despite being a role add action, it should throw an error, although probably not a WSOD with the message...

I'm a bit stumped as to what is causing this.

infojunkie’s picture

Does calling the same action from VBO work for you?

GameCharmer’s picture

No clue now to directly call an action from VBO. I don't think I even have an ACP panel or whatever for VBO.

I can use the user control panel to easily add roles to the users, so I know the role itself is working just fine.

bojanz’s picture

Priority: Critical » Normal
Status: Active » Needs review

There's still a patch in here.

bojanz’s picture

Version: 6.x-1.9 » 6.x-1.x-dev
Status: Needs review » Needs work

Just marked #1275450: BUG? Fatal error: Unsupported operand types when trying to add a new action related to add a new role to a user as duplicate. The patch fixed the error in that case, but adding the role still fails, so I'm changing issue status.

Rosamunda’s picture

subscribing :)

bojanz’s picture

Status: Needs work » Closed (works as designed)

Okay, I've taken a look at this.

This is a problem in the Quiz module. I guess when the action is run from Quiz, $context['add_roles'] is empty, hence no roles being added.
And $user->roles is always supposed to be an array, so Quiz might not be passing the right object at all (or not formatting it correctly).

I have no knowledge of the Quiz codebase, so I can't help further. Do a dsm($user); dsm($context); to see what data gets passed, then open an issue in their queue.

caspervoogt’s picture

This patch alone didn't work for me.. in my case the specific error was:
"Fatal error: Unsupported operand types in /home/www.mysite.com/public_html/sites/all/modules/views_bulk_operations/actio... on line 71"

Line 71 was:

if (!empty($add_roles)) {
    $roles += $add_roles;  //Line 71
  }

I changed this to:

if (!empty($add_roles)) {
    //$roles += $add_roles; //disabled because the space before the + or otherwise the += operand was wreaking havoc. Seems to me array_push can work in this case;
	array_push($roles,$add_roles);
  }

That worked for me. In my case the fatal error meant that user registering on the site could not get subscribed to our Simplenews newsletters. This fix plus the patch above worked for me.

marleo’s picture

I'm trying to fire an action to modify user roles from a quiz. The above patch stopped my WSOD at the end of the quiz, but didn't update the user role and also I got this error:
warning: array_push() expects parameter 1 to be array, null given in /path/to/sites/all/modules/views_bulk_operations/actions/user_roles.action.inc on line 72

D6.28
Quiz 6.x-4.4
VBO 6.x-1.16

caspervoogt’s picture

sounds like $roles is not getting set. Maybe try this, though I have not tested this:

if (!empty($add_roles)) {
  //$roles += $add_roles; //disabled because the space before the + or otherwise the += operand was wreaking havoc. Seems to me array_push can work in this case;
  $roles = array();
  array_push($roles,$add_roles);
  }

Or ...

if (!empty($add_roles)) {
  //$roles += $add_roles; //disabled because the space before the + or otherwise the += operand was wreaking havoc. Seems to me array_push can work in this case;
  $roles = array();
  $roles[]=$add_roles;
  }

Also maybe try replacing "$roles = array();" with "global $roles;" .. not sure about that though.