Skip to content

Commit

Permalink
Pre-generate form security tokens
Browse files Browse the repository at this point in the history
Avoid performance issues in bug view page

Fixes #18016
  • Loading branch information
cproensa authored and dregad committed Mar 7, 2016
1 parent d7953e1 commit 6332942
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions bugnote_view_inc.php
Expand Up @@ -121,6 +121,10 @@
$t_can_delete_all_bugnotes = access_has_bug_level( config_get( 'delete_bugnote_threshold' ), $f_bug_id );
$t_can_change_view_state_all_bugnotes = $t_can_edit_all_bugnotes && access_has_bug_level( config_get( 'change_view_status_threshold' ), $f_bug_id );

# Pre-generate form security tokens to avoid performance issues
$t_security_token_state = form_security_token( 'bugnote_set_view_state' );
$t_security_token_delete = form_security_token( 'bugnote_delete' );

for( $i=0; $i < $t_num_notes; $i++ ) {
$t_bugnote = $t_bugnotes[$i];

Expand Down Expand Up @@ -215,20 +219,20 @@

# show edit button if the user is allowed to edit this bugnote
if( $t_can_edit_bugnote ) {
print_button( 'bugnote_edit_page.php?bugnote_id='.$t_bugnote->id, lang_get( 'bugnote_edit_link' ) );
print_button( 'bugnote_edit_page.php?bugnote_id='.$t_bugnote->id, lang_get( 'bugnote_edit_link' ), null, OFF );
}

# show delete button if the user is allowed to delete this bugnote
if( $t_can_delete_bugnote ) {
print_button( 'bugnote_delete.php?bugnote_id='.$t_bugnote->id, lang_get( 'delete_link' ) );
print_button( 'bugnote_delete.php?bugnote_id='.$t_bugnote->id, lang_get( 'delete_link' ), null, $t_security_token_delete );
}

# show make public or make private button if the user is allowed to change the view state of this bugnote
if( $t_can_change_view_state ) {
if( VS_PRIVATE == $t_bugnote->view_state ) {
print_button( 'bugnote_set_view_state.php?private=0&bugnote_id=' . $t_bugnote->id, lang_get( 'make_public' ) );
print_button( 'bugnote_set_view_state.php?private=0&bugnote_id=' . $t_bugnote->id, lang_get( 'make_public' ), null, $t_security_token_state );
} else {
print_button( 'bugnote_set_view_state.php?private=1&bugnote_id=' . $t_bugnote->id, lang_get( 'make_private' ) );
print_button( 'bugnote_set_view_state.php?private=1&bugnote_id=' . $t_bugnote->id, lang_get( 'make_private' ), null, $t_security_token_state );
}
}
}
Expand Down

0 comments on commit 6332942

Please sign in to comment.