Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improve handling of reminders' recipients list truncation

Replaced the previous method of truncating the list to a hardcoded
number of entries (50), to a more robust approach based on the size of
the underlying database field (250 chars, note_attr in bugnote table).

Added a message on the REMINDER bugnote, to inform user that the list of
recipients stored with the note, was actually truncated (Users should
refer to the issue's history to see who actually received the reminder).

This functionality relies on a hack, i.e. to indicate that the list was
truncated, bug_reminder.php is not storing the trailing delimiter in the
note_attr field, and this is picked up in bugnote_view_inc.php to
display the note to the user's attention.

Fixes #15470
  • Loading branch information...
commit 4429c8f7e08f70a31ba8dfd130867d6fdd1ab2d1 1 parent 97eb148
Damien Regad dregad authored
Showing with 36 additions and 12 deletions.
  1. +11 −6 bug_reminder.php
  2. +23 −6 bugnote_view_inc.php
  3. +2 −0  lang/strings_english.txt
17 bug_reminder.php
View
@@ -94,14 +94,19 @@
# Add reminder as bugnote if store reminders option is ON.
if ( ON == config_get( 'store_reminders' ) ) {
- if ( count( $f_to ) > 50 ) { # too many recipients to log, truncate the list
- $t_to = array();
- for ( $i=0; $i<50; $i++ ) {
- $t_to[] = $f_to[$i];
+ # Build list of recipients, truncated to note_attr fields's length
+ $t_attr = '|';
+ $t_length = 0;
+ foreach( $f_to as $t_id ) {
+ $t_recipient = $t_id . '|';
+ $t_length += strlen( $t_recipient );
+ if( $t_length > 250 ) {
+ # Remove trailing delimiter to indicate truncation
+ $t_attr = rtrim( $t_attr, '|' );
+ break;
}
- $f_to = $t_to;
+ $t_attr .= $t_recipient;
}
- $t_attr = '|' . implode( '|', $f_to ) . '|';
bugnote_add( $f_bug_id, $f_body, 0, config_get( 'default_reminder_view_status' ) == VS_PRIVATE, REMINDER, $t_attr, NULL, FALSE );
}
29 bugnote_view_inc.php
View
@@ -242,14 +242,31 @@
<?php
switch ( $t_bugnote->note_type ) {
case REMINDER:
- echo '<em>' . lang_get( 'reminder_sent_to' ) . ': ';
- $t_note_attr = utf8_substr( $t_bugnote->note_attr, 1, utf8_strlen( $t_bugnote->note_attr ) - 2 );
- $t_to = array();
- foreach ( explode( '|', $t_note_attr ) as $t_recipient ) {
- $t_to[] = prepare_user_name( $t_recipient );
+ echo '<em>';
+
+ # List of recipients; remove surrounding delimiters
+ $t_recipients = trim( $t_bugnote->note_attr, '|' );
+
+ if( empty( $t_recipients ) ) {
+ echo lang_get( 'reminder_sent_none' );
+ } else {
+ # If recipients list's last char is not a delimiter, it was truncated
+ $t_truncated = ( '|' != utf8_substr( $t_bugnote->note_attr, utf8_strlen( $t_bugnote->note_attr ) - 1 ) );
+
+ # Build recipients list for display
+ $t_to = array();
+ foreach ( explode( '|', $t_recipients ) as $t_recipient ) {
+ $t_to[] = prepare_user_name( $t_recipient );
+ }
+
+ echo lang_get( 'reminder_sent_to' ) . ': '
+ . implode( ', ', $t_to )
+ . ( $t_truncated ? ' (' . lang_get( 'reminder_list_truncated' ) . ')' : '' );
}
- echo implode( ', ', $t_to ) . '</em><br /><br />';
+
+ echo '</em><br /><br />';
break;
+
case TIME_TRACKING:
if ( access_has_bug_level( config_get( 'time_tracking_view_threshold' ), $f_bug_id ) ) {
echo '<div class="time-tracked">', lang_get( 'time_tracking_time_spent') . ' ' . $t_time_tracking_hhmm, '</div>';
2  lang/strings_english.txt
View
@@ -471,6 +471,8 @@ If you requested this verification, visit the following URL to change your passw
'sent_you_this_reminder_about' => 'sent you this reminder about',
'bug_reminder' => 'Send a reminder',
'reminder_sent_to' => 'Reminder sent to',
+ 'reminder_sent_none' => 'No reminders could be sent',
+ 'reminder_list_truncated' => 'recipients list truncated, refer to Issue History for full list',
'bug_send_button' => 'Send',
'reminder' => 'Reminder',
'reminder_explain' => 'This note will be sent to the recipients listed requesting feedback on this issue.',
Please sign in to comment.
Something went wrong with that request. Please try again.