Skip to content

Commit 0da29a6

Browse files
committed
Fixed issue with keys for apcu being different in newer versions.
1 parent ae53e36 commit 0da29a6

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

cache.php

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ function percentage( $a, $b ) {
99
return ( $a / $b ) * 100;
1010
}
1111

12+
function has_key( $arr, $key1=null, $key2=null, $key3=null ) {
13+
if( isset( $arr[$key1] ) )
14+
return $key1;
15+
if( isset( $arr[$key2] ) )
16+
return $key2;
17+
if( isset( $arr[$key3] ) )
18+
return $key3;
19+
20+
return null;
21+
}
22+
23+
function get_key( $arr, $key1=null, $key2=null, $key3=null ) {
24+
$key = has_key($arr, $key1, $key2, $key3 );
25+
if( empty( $key ) )
26+
return null;
27+
28+
return $arr[$key];
29+
}
30+
1231
function opcache_mem( $key ) {
1332
global $opcache;
1433

@@ -75,7 +94,7 @@ function sort_url($on) {
7594

7695
$query = preg_replace( '#sort=[^&]+&?#', '', $query );
7796
$query = preg_replace( '#order=[^&]+&?#', '', $query );
78-
97+
7998
if( !isset( $_GET['order'] ) )
8099
$_GET['order'] = '';
81100

@@ -116,7 +135,7 @@ function sort_list(&$list) {
116135

117136
if( isset( $_GET['action'] ) && $_GET['action'] == 'op_delete' ) {
118137
$selector = get_selector();
119-
138+
120139
foreach( $opcache['scripts'] as $key => $value ) {
121140
if( !preg_match( $selector, $key) ) continue;
122141

@@ -273,7 +292,7 @@ function sort_list(&$list) {
273292
<table>
274293
<thead>
275294
<tr>
276-
<th><a href="<?=sort_url('key')?>">Key</a></th>
295+
<th><a href="<?=sort_url(has_key('key', 'info'))?>">Key</a></th>
277296
<th><a href="<?=sort_url('nhits')?>">Hits</a></th>
278297
<th><a href="<?=sort_url('mem_size')?>">Size</a></th>
279298
<th><a href="<?=sort_url('ttl')?>">TTL</a></th>
@@ -286,17 +305,17 @@ function sort_list(&$list) {
286305

287306
<tbody>
288307
<?php foreach( sort_list($apc['cache']['cache_list']) as $item ):
289-
$expired = !isset( $_GET['apc_show_expired'] ) && $item['ttl'] > 0 && $item['mtime'] + $item['ttl'] < time();
290-
if( !preg_match(get_selector(), $item['key']) || $expired ) continue;?>
308+
$expired = !isset( $_GET['apc_show_expired'] ) && $item['ttl'] > 0 && get_key($item, 'mtime', 'modification_time') + $item['ttl'] < time();
309+
if( !preg_match(get_selector(), get_key($item, 'key', 'info')) || $expired ) continue;?>
291310
<tr>
292-
<td><?=$item['key']?></td>
311+
<td><?=get_key($item, 'key', 'info')?></td>
293312
<td><?=$item['nhits']?></td>
294313
<td><?=human_size($item['mem_size'])?></td>
295314
<td><?=$item['ttl']?></td>
296-
<td><?=date('Y-m-d H:i', $item['mtime'] + $item['ttl'] )?></td>
315+
<td><?=date('Y-m-d H:i', get_key($item, 'mtime', 'modification_time') + $item['ttl'] )?></td>
297316
<td>
298-
<a href="?action=apc_delete&selector=<?=urlencode('^'.$item['key'].'$')?>">Delete</a>
299-
<a href="?action=apc_view&selector=<?=urlencode($item['key'])?>">View</a>
317+
<a href="?action=apc_delete&selector=<?=urlencode('^'.get_key($item, 'key', 'info').'$')?>">Delete</a>
318+
<a href="?action=apc_view&selector=<?=urlencode(get_key($item, 'key', 'info'))?>">View</a>
300319
</td>
301320
</tr>
302321
<?php endforeach; ?>

0 commit comments

Comments
 (0)