From 39be89ba4945238f6311454283a66930b94577be Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Mon, 23 Sep 2013 10:11:16 +1000 Subject: [PATCH] ?/debug/apc --- inc/config.php | 2 ++ inc/mod/pages.php | 13 +++++++++++++ mod.php | 1 + templates/mod/debug/apc.html | 23 +++++++++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 templates/mod/debug/apc.html diff --git a/inc/config.php b/inc/config.php index 5105c25f..9ca4cfeb 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1340,6 +1340,8 @@ $config['mod']['news_delete'] = ADMIN; // Execute un-filtered SQL queries on the database (?/debug/sql) $config['mod']['debug_sql'] = DISABLED; + // Look through all cache values for debugging when APC is enabled (?/debug/apc) + $config['mod']['debug_apc'] = ADMIN; // Edit the current configuration (via web interface) $config['mod']['edit_config'] = ADMIN; // View ban appeals diff --git a/inc/mod/pages.php b/inc/mod/pages.php index bae00a0f..4346cf94 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -2354,3 +2354,16 @@ function mod_debug_sql() { mod_page(_('Debug: SQL'), 'mod/debug/sql.html', $args); } +function mod_debug_apc() { + global $config; + + if (!hasPermission($config['mod']['debug_apc'])) + error($config['error']['noaccess']); + + if ($config['cache']['enabled'] != 'apc') + error('APC is not enabled.'); + + $cached_vars = new APCIterator('user', '/^' . $config['cache']['prefix'] . '/'); + + mod_page(_('Debug: APC'), 'mod/debug/apc.html', array('cached_vars' => $cached_vars)); +} diff --git a/mod.php b/mod.php index ca6d971e..cf6423ed 100644 --- a/mod.php +++ b/mod.php @@ -89,6 +89,7 @@ $pages = array( // these pages aren't listed in the dashboard without $config['debug'] '/debug/antispam' => 'debug_antispam', '/debug/recent' => 'debug_recent_posts', + '/debug/apc' => 'debug_apc', '/debug/sql' => 'secure_POST debug_sql', // This should always be at the end: diff --git a/templates/mod/debug/apc.html b/templates/mod/debug/apc.html new file mode 100644 index 00000000..53f59eb0 --- /dev/null +++ b/templates/mod/debug/apc.html @@ -0,0 +1,23 @@ + + + + + + + + + + {% for var in cached_vars %} + + + + + + + + + {% endfor %} +
KeyHitsCreatedExpiresSizeValue
{{ var.key }}{{ var.num_hits }}{{ var.creation_time|ago }} ago{{ (var.creation_time + var.ttl)|until }} (ttl: {{ var.ttl }}s){{ var.mem_size }} bytes + {% set value = var.value|json_encode %} + {{ value[:80]|e('html') }}{% if value|length > 80 %}…{% endif %} +
\ No newline at end of file