- Status changed to Needs review
over 1 year ago 5:06am 17 July 2023 - 🇺🇸United States SocialNicheGuru
is this still an issue for Social 13?
Changing from 11.9.x to investigate
We have configured the create_post_group
message template to create an activity on group stream (destination stream_group
) when post is created. But activity is not displayed on the stream when post is created.
I've checked - post is created, activity is created, but it's not displayed. Reason - field_activity_recipient_group
is empty for this activity.
I've checked some other messages with the same destination type, but related to other entities - it's the same - entity and activity are created, but recipient group field is empty.
After some investiagtions it turned out that $recipients
variable in activity_creator_message_insert()
is corrupted. So there is a code (line 96 of activity_creator.module
):
$recipients = $plugin->getRecipients($data, $data['last_uid'], 0);
and recipients looks like this:
array(
0 => array(
'target_type' => 'group',
'target_id' => 876,
),
).
But below there is the following code (line 115 of activity_creator.module
):
$activity_creator_data['recipient'] = $recipients[$recipients_key];
This code is looking for $recipients[876]
but... this item does not exist.
Create post (or other entity) that should be displayed on group stream.
I guess other destinations like stream_profile, stream_explore, stream_home may be affected as well.
I've found 2 ways to fix this bug:
1. Add these lines to activity_creator_message_insert()
(at line 100 of activity_creator.module
):
// Let's use entity id as array key.
$recipients = array_combine(array_column($recipients, 'target_id'), $recipients);
2. Update GroupActivityContext->getRecipients()
(see line 42 of GroupActivityContext.php
):
// Replace '$recipients[]' with '$recipients[$gid]'.
$recipients[$gid] = [
'target_type' => 'group',
'target_id' => $gid,
];
What solution is more preferable?
Is it possible to fix it in the next release?
Needs review
13.0
Code (back-end)
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
is this still an issue for Social 13?
Changing from 11.9.x to investigate