Skip to:
Content

BuddyPress.org

Opened 3 years ago

Closed 3 years ago

#8674 closed defect (bug) (worksforme)

[10.2.0] Bug in bd-activity-comment-notifier/core/functions.php:139-150

Reported by: jesusinica's profile jesusinica Owned by:
Milestone: Priority: normal
Severity: normal Version: 10.2.0
Component: Activity Keywords:
Cc:

Description

Please accept my apologies if the format of the report isn't what is expected, it is my first bug report in BuddyPress. I'd love to send a merge request with the fix, but I haven't found what's the process.

The bug is causing notifications to show an incorrect message when $total_user is 1 due to an incorrect logic within this if statement:


  if ($total_user == 1){
    if ( $activity->user_id == reset( $users ) ) {
        $text = sprintf( __( '%s also commented on his/her own post', 'bp-activity-comment-notifier' ), $commenting_users, bp_core_get_user_displayname( $activity->user_id ) );
    } else {
        $text = sprintf( __( '%s also commented on %s\'s post', 'bp-activity-comment-notifier' ), $commenting_users, bp_core_get_user_displayname( $activity->user_id ) );
    }
  }
  if ($total_user == 2){
    $text = sprintf( __( '%s also commented on %s\'s post', 'bp-activity-comment-notifier' ), $commenting_users, bp_core_get_user_displayname( $activity->user_id ) );
  }
  else { // <---- This else is overwritting the notification created when $total_user = 1
    $text = sprintf(__('%s and %s others also commented on %s\'s post', 'bp-activity-comment-notifier'), $commenting_users, $count, bp_core_get_user_displayname($activity->user_id));
  }

It feels like this section should look like this:

if ($total_user == 1) {
    if ($activity->user_id == reset($users)) {
        $text = sprintf(__('%s also commented on his/her own post', 'bp-activity-comment-notifier'), $commenting_users, bp_core_get_user_displayname($activity->user_id));
    } else {
        $text = sprintf(__('%s also commented on %s\'s post', 'bp-activity-comment-notifier'), $commenting_users, bp_core_get_user_displayname($activity->user_id));
    }
} elseif ($total_user == 2) {
    $text = sprintf(__('%s also commented on %s\'s post', 'bp-activity-comment-notifier'), $commenting_users, bp_core_get_user_displayname($activity->user_id));
} else {
    $text = sprintf(__('%s and %s others also commented on %s\'s post', 'bp-activity-comment-notifier'), $commenting_users, $count, bp_core_get_user_displayname($activity->user_id));
}

Change History (3)

#1 @imath
3 years ago

  • Priority changed from high to normal

Hi,

Here’s the PR process:
https://bpdevel.wordpress.com/2022/03/06/using-pr-to-share-your-patches-on-buddypress-trac/

Thanks for your report. I’ll look at it asap.

#2 @oztaser
3 years ago

Hi @jesusinica, @imath,

These lines don't belongs to BuddyPress. It looks like the problem is here related to plugin called BuddyPress Activity Comment Notifier. I suggest you to open a new topic in the plugin support.

#3 @imath
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Thanks a lot for your review @oztaser. Let's close this ticket.

Note: See TracTickets for help on using tickets.