Problem

When editing a post that was placed on a user's timeline the value for the field_recipient_user gets lost. This causes the activity that's displayed on the users stream to display the [activity:field_activity_recipient_user_display_name] token because the activity_creator_tokens has no value to replace it with.

Solution

Ensure the post edit form doesn't change values that are not exposed to the editing user.

CommentFileSizeAuthor
Screen Shot 2018-04-18 at 15.32.14.png33.17 KBkingdutch

Comments

Kingdutch created an issue. See original summary.

brhane’s picture

Assigned: Unassigned » brhane

This issue is caused when we are editing a post on a user's timeline as the save function, from the post form, does not have the User parameter when you edit the post. So its better if we provide a solution to get the right replacement, or by making sure we don't replace the tokens at all on the Edit form since these values don't change, only the post message does. See the current logic at this function:

if (isset($display) && ($display_id = $display->get('id'))) {
if ($display_id === $this->postViewProfile) {
$account_profile = \Drupal::routeMatch()->getParameter('user');
$this->entity->get('field_recipient_user')->setValue($account_profile);
}
}
elseif ($display_id === $this->postViewGroup) {
$group = \Drupal::routeMatch()->getParameter('group');
$this->entity->get('field_recipient_group')->setValue($group);
}

brhane’s picture

Assigned: brhane » Unassigned

Hello,
I have already created a PR for this at github.com and here is the patch.
https://patch-diff.githubusercontent.com/raw/goalgorilla/open_social/pul...

brhane’s picture

Status: Active » Needs review
jaapjan’s picture

Assigned: Unassigned » ronaldtebrake
ronaldtebrake’s picture

Status: Needs review » Reviewed & tested by the community

Hi Brhane,

Code works like a charm :)
Great work!

jaapjan’s picture

Assigned: ronaldtebrake » Unassigned
Status: Reviewed & tested by the community » Fixed

If it is merged to 8.x we can mark the status as "Fixed". Thanks!

Status: Fixed » Closed (fixed)

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