Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Have a rule component that uses the 'Set data value' for a text field in a node that has a chatroom field. Get this error when I try to run the rule.
Fatal error: Cannot use object of type Chatroom as array in /home/edelib/public_html/sites/all/modules/chatroom/chatroom.module on line 226
works fine if I delete the chatroom field from the node.
Thanks
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedcan you post more information for me to reproduce?
i'm unfamiliar with rules.
Comment #2
blackclover CreditAttribution: blackclover commentedSure. Thanks appreciate the quick response.
1. add a chatroom field to a content type.
2. Create a VBO (views bulk operations module) view page that includes that content type / node.
3. Navigate to admin/config/workflow/rules/components and + Add new component.
4. Component plugin select 'Rule' -> Continue
5. Name the component "Chatroom test"
6. Under Variables -> Data type = node, label = node, machine name = node -> Continue
Under Conditions
7. + Add Condition -> "Content is of Type" then select the content type with the chatroom field -> Save
Under Actions
8. + Add action -> "Set data value" -> Data Selector node:body (or some other text field in the node) -> Value 'type in some text' -> Save
This creates a simple component that adds the text to the field and saves the node when it's executed from a VBO view.
Navigate to admin/structure/views
Edit the VBO view page you created earlier -> Go to the Bulk Operations Content column (under fields) and select your "Chatroom Test" component from the pick list.
Apply and save the view - > should redirect you to the view page with your node and a checkbox on that row. Check the box and pick "Chatroom test" from the Operations select list -> Execute
The component should fire and the error should trigger. If you remove the chatroom field the component works.
Hope this helps.
Comment #3
eDeliberation CreditAttribution: eDeliberation commentedI work with blackclover - we're still stuck with this.
One question we had was why Rules is calling the module since we aren't updating the Chatroom field.
Another related question was what must be done to a module to allow it to be Rules enabled? This is related to issue http://drupal.org/node/1783218 "Make the chatroom field available in rules" Wondering if there is a connection.
Does an expert on Rules have an insight on this?
Comment #4
michlis CreditAttribution: michlis commentedI think this issue is not specific to Rules, because I had same problem when trying to apply actions (publish/unpublish etc.) from content admin page on node with chatroom field .
I believe the problem is in
chatroom_field_update()
which expects$item['chatroom']
to be array.This is true when you create/edit node with chatroom, but not when you modify node e.g. from content admin page (most likely Rules too). Then
$item['chatroom']
is an object and not all properties names match keys from array.This is
$item['chatroom']
dump from later case, which gives error.This is
$item['chatroom']
dump when creating/editing node, works fineI assume (at least for now) that chatroom update is needed only when you create/edit node with chatroom, so my workaround for this issue is to proceed with update only if
$item['chatroom']
is array, by addingif (is_array($item['chatroom']))
right afterforeach
and before creating$chatroom
variable.Tested to remove the error and doesn't break node create/edit process.
However, this is definitely not a proper solution, so I hope someone with Chatroom and Field API knowledge can fix it properly.
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedretitling, because i care less about rules than the core node admin screen.
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedfixed with this commit:
http://drupalcode.org/project/chatroom.git/commitdiff/fe48064
not convinced i'm not doing something else wrong, but one fix at a time.