Skip to content

Commit

Permalink
Fix possible duplicate hashes for toggle
Browse files Browse the repository at this point in the history
Pass the index, which makes the lines with
same key unique.
  • Loading branch information
aidvu committed Jun 3, 2020
1 parent 2ca15ef commit e18a4f2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -656,9 +656,9 @@ function stats() {
echo "<div id='object-cache-stats-menu-target-" . esc_attr( $group_name ) . "' class='object-cache-stats-menu-target' $current>\n";
echo '<h3>' . esc_html( $group_titles[ $group ] ) . '</h3>' . "\n";
echo "<pre>\n";
foreach ( $this->group_ops[ $group ] as $o => $arr ) {
printf( '%3d ', $o );
echo $this->get_group_ops_line( $arr );
foreach ( $this->group_ops[ $group ] as $index => $arr ) {
printf( '%3d ', $index );
echo $this->get_group_ops_line( $index, $arr );
}
echo "</pre>\n";
echo "</div>";
Expand All @@ -667,7 +667,7 @@ function stats() {
echo "</div>";
}

function get_group_ops_line( $arr ) {
function get_group_ops_line( $index, $arr ) {
// operation
$line = "{$arr[0]} ";

Expand All @@ -693,7 +693,7 @@ function get_group_ops_line( $arr ) {
// backtrace
$bt_link = '';
if ( isset( $arr[6] ) ) {
$key_hash = md5( $json_encoded_key );
$key_hash = md5( $index . $json_encoded_key );
$bt_link = " <small><a href='#' onclick='memcachedToggleVisibility( \"object-cache-stats-debug-$key_hash\" );'>Toggle Backtrace</a></small>";
$bt_link .= "<pre id='object-cache-stats-debug-$key_hash' style='display:none'>" . esc_html( $arr[6] ) . "</pre>";
}
Expand Down

0 comments on commit e18a4f2

Please sign in to comment.