You are here

function apc_shutdown in APC - Alternative PHP Cache 7

See apc_init() which registers this function as a shutdown function. Displays apc stats in the footer.

1 string reference to 'apc_shutdown'
apc_init in ./apc.module
Implementation of hook_init().

File

./apc.module, line 85
This integrates the drupal APC cache module.

Code

function apc_shutdown() {
  global $apc_statistics;

  // Don't call theme() during shutdown if the registry has been rebuilt (such
  // as when enabling/disabling modules on admin/build/modules) as things break.
  // Instead, simply exit without displaying admin statistics for this page
  // load.  See http://drupal.org/node/616282 for discussion.
  if (!function_exists('theme_get_registry') || !theme_get_registry()) {
    return;
  }

  // Try not to break non-HTML pages.
  if (function_exists('drupal_get_http_header')) {
    $header = drupal_get_http_header('content-type');
    if ($header) {
      $formats = array(
        'xml',
        'javascript',
        'json',
        'plain',
        'image',
        'application',
        'csv',
        'x-comma-separated-values',
      );
      foreach ($formats as $format) {
        if (strstr($header, $format)) {
          return;
        }
      }
    }
  }
  if (isset($apc_statistics) && is_array($apc_statistics)) {
    print '<div id="apc-devel"><h2>' . t('APC statistics') . '</h2>';
    $rows = array();
    foreach ($apc_statistics as $row) {
      if (is_array($row[2])) {
        $row[2] = implode(',<br />', $row[2]);
      }
      $rows[] = $row;
    }
    print theme('table', array(
      'header' => array(
        'Type',
        t('Bin'),
        t('Cid(s)'),
      ),
      'rows' => $rows,
    ));
    print '</div>';
  }
}