buddydev / mediapress

The Most advanced Media Gallery Plugin for BuddyPress
https://buddydev.com/mediapress/
32 stars 17 forks source link

Incorrect number of images/media displayed in activity feed #16

Closed jazzsequence closed 9 years ago

jazzsequence commented 9 years ago

image

This appears to be coming from this line: https://github.com/buddydev/mediapress/blob/master/core/activity/template.php#L152

...except that when I var_dump $media_ids I get an empty array, so the count is always 0.

jazzsequence commented 9 years ago

...which is really weird because this returns an array of IDs:

var_dump(mpp_activity_get_attached_media_ids($activity->id));

jazzsequence commented 9 years ago

This line appears to be the issue:

https://github.com/buddydev/mediapress/blob/master/core/activity/template.php#L165

apply_filters is being run twice. PR forthcoming.

sbrajesh commented 9 years ago

Hi Chris, Please give me an hour . I am looking into it. Most probably it is caused by mpp_activity_get_attached_media_ids()

jazzsequence commented 9 years ago

PR #17

sbrajesh commented 9 years ago

Hi, The problem is if we remove that filter, It will not change the action for the upload to groups as you can see here. https://github.com/buddydev/mediapress/blob/master/modules/groups/hooks.php#L69

sbrajesh commented 9 years ago

Finally found the issue. On line 153 , we are popping the media ids array to fetch one of the media https://github.com/buddydev/mediapress/blob/master/core/activity/template.php#L153

and this is causing the actual count to decrease by 1.

jazzsequence commented 9 years ago

That makes sense. I will look for the update. I'm not familiar with array_pop so I didn't pay much attention to it. :)

sbrajesh commented 9 years ago

Fixed in 8569e247e547ddf

jazzsequence commented 9 years ago

:+1: This looks good, too.

sbrajesh commented 9 years ago

Thank you :)