[buddypress-trac] [BuddyPress Trac] #8674: [10.2.0] Bug in bd-activity-comment-notifier/core/functions.php:139-150
buddypress-trac
noreply at wordpress.org
Fri Apr 1 19:31:14 UTC 2022
#8674: [10.2.0] Bug in bd-activity-comment-notifier/core/functions.php:139-150
--------------------------+-----------------------------
Reporter: jesusinica | Owner: (none)
Type: defect (bug) | Status: new
Priority: high | Milestone: Awaiting Review
Component: Activity | Version: 10.2.0
Severity: normal | Keywords:
--------------------------+-----------------------------
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:
{{{#!php
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:
{{{#!php
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));
}
}}}
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/8674>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list