Skip to:
Content

Opened 3 months ago

Last modified 4 weeks ago

#7329 new defect (bug)

Notice: Trying to get property of non-object

Reported by: slaFFik Owned by:
Milestone: 2.7.5 Priority: normal
Severity: normal Version: 2.7
Component: Administration Keywords: 2nd-opinion has-patch
Cc:

Description (last modified by slaFFik)

Posted a comment to post, after that opened Activity management page in wp-admin area - saw this notice:

Notice: Trying to get property of non-object in \wp-content\plugins\buddypress\src\bp-activity\bp-activity-template.php on line 2254

Current BuddyPress trunk

Attachments (2)

7329.patch (2.5 KB) - added by slaFFik 3 months ago.
The easiest but not elegant fix of this.
7329.02.patch (4.2 KB) - added by r-a-y 5 weeks ago.

Download all attachments as: .zip

Change History (15)

#1 @slaFFik
3 months ago

  • Description modified (diff)

#2 @slaFFik
3 months ago

That's because $activities_template global in bp_activity_get_comment_depth() is empty, because we don't have it in admin area.

Last edited 3 months ago by slaFFik (previous) (diff)

@slaFFik
3 months ago

The easiest but not elegant fix of this.

#3 @slaFFik
3 months ago

  • Keywords 2nd-opinion has-patch added; needs-patch removed

#4 @DJPaul
2 months ago

Is this a regression introduced in 2.7? Did it work in 2.6?

#5 @slaFFik
2 months ago

@DJPaul
I was not able to replicate on WordPress 4.5.x and 4.6.x and BP 2.6.x.
Once I updated to BuddyPress 2.7.2 on Plugins page - instantly got this notice.

So yes, this is a regression in 2.7.

#6 @DJPaul
8 weeks ago

In future patches, try to keep unrelated code improvements (all the spacing) outside of bug fixes.

#7 @DJPaul
8 weeks ago

I did some git bisect (best tool on the planet) and discovered this was caused in 2.7 by r10947. @r-a-y do you have time to look at this patch and see if it's a good fix?

This ticket was mentioned in Slack in #buddypress by djpaul. View the logs.


8 weeks ago

This ticket was mentioned in Slack in #buddypress by tw2113. View the logs.


7 weeks ago

#10 @DJPaul
7 weeks ago

  • Milestone changed from 2.7.3 to 2.7.4

This ticket was mentioned in Slack in #buddypress by slaffik. View the logs.


6 weeks ago

#12 @r-a-y
5 weeks ago

  • Version set to 2.7

Thanks @slaFFik for discovering this bug and sorry for getting to this kinda late.

The main thing we need to address here is finding the current activity comment depth when we're not in the activity comment loop.

02.patch is an attempt at this.

This is what is happening in the patch:

  • When we pass $comment to bp_activity_get_comment_depth(), we pull up the root activity update and the entire activity comment tree.
  • Next, we try to iterate over the entire tree to find the current comment. Once we've found the comment, we use the calculated depth from BP_Activity_Activity:get_activity_comments(). This can be kind of intensive depending on how many comments are in the tree.
  • Lastly, since activity items in the Activity dashboard are displayed in stream mode, we need to iterate the depth number so bp_blogs_can_comment_reply() knows when to disable activity comment replies. This is a little bit of a hack, but if we want to avoid this, we can add a conditional so this is only done in the WP admin dashboard. Or, we can also iterate the depth in bp_blogs_can_comment_reply(). I think this makes more sense.
Last edited 5 weeks ago by r-a-y (previous) (diff)

@r-a-y
5 weeks ago

#13 @DJPaul
4 weeks ago

  • Milestone changed from 2.7.4 to 2.7.5
Note: See TracTickets for help on using tickets.