Skip to content

Commit

Permalink
Re-enable Smarty when using Profiler Extension >= 1.2.2, always enabl…
Browse files Browse the repository at this point in the history
…e layer mode when using Profiler Extension >= 1.2.2
  • Loading branch information
beberlei committed Nov 9, 2014
1 parent e2c27f9 commit 67cfc28
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/main/QafooLabs/Profiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,23 @@ class Profiler

private static function getDefaultArgumentFunctions()
{
return array(
$argumentFunctions = array(
'PDOStatement::execute',
'PDO::exec',
'PDO::query',
'mysql_query',
'mysqli_query',
'mysqli::query',
'curl_exec',
//'file_get_contents', //enable again when only http calls get extracted
//'file_put_contents', //enable again when only http calls get extracted
'Twig_Template::render',
//'Smarty::fetch',
//'Smarty_Internal_TemplateBase::fetch',
);

if (version_compare(phpversion("qafooprofiler"), "1.2.2") >= 0) {
$argumentFunctions[] = 'Smarty::fetch';
$argumentFunctions[] = 'Smarty_Internal_TemplateBase::fetch';
}

return $argumentFunctions;
}

private static function getDefaultLayerFunctions()
Expand Down Expand Up @@ -235,25 +238,22 @@ public static function start($apiKey, $sampleRate = 20, array $options = array()
return;
}

if (!isset($_SERVER['QAFOO_PROFILER_ENABLE_LAYERS']) || !$_SERVER['QAFOO_PROFILER_ENABLE_LAYERS']) {
return;
}

if ((self::$extensionFlags & self::EXT_LAYERS) === 0) {
return;
}

if (!isset($options['layers'])) {
if (!isset($_SERVER['QAFOO_PROFILER_ENABLE_LAYERS']) || !$_SERVER['QAFOO_PROFILER_ENABLE_LAYERS']) {
$options['layers'] = array();
} else if (!isset($options['layers'])) {
$options['layers'] = self::getDefaultLayerFunctions();
}

$enable = self::$extensionPrefix . '_layers_enable';
if ($enable === 'xhprof_layers_enable') {
$enable($options['layers']);
} else {
$enable($options['layers'], self::$framework);
if (!$options['layers'] && !self::$framework) {
return;
}

qafooprofiler_layers_enable($options['layers'], self::$framework);

self::$sampling = true;
}

Expand Down Expand Up @@ -346,18 +346,18 @@ private static function init($apiKey)
self::$uid = null;

if (function_exists('qafooprofiler_enable')) {
$version = phpversion('qafooprofiler');

self::$extensionPrefix = 'qafooprofiler';
self::$extensionFlags = (self::EXT_EXCEPTION | self::EXT_LAYERS | self::EXT_FATAL | self::EXT_TRANSACTION_NAME);
self::$customVars['xhpv'] = 'qp-' . phpversion('qafooprofiler');
self::$extensionFlags = (self::EXT_EXCEPTION | self::EXT_FATAL | self::EXT_TRANSACTION_NAME);
self::$extensionFlags |= (version_compare($version, "1.2.2") >= 0) ? self::EXT_LAYERS : 0;
self::$customVars['xhpv'] = 'qp-' . $version;
} else if (function_exists('xhprof_enable')) {
self::$extensionPrefix = 'xhprof';
self::$extensionFlags = (version_compare(phpversion('xhprof'), '0.9.7') >= 0) ? (self::EXT_LAYERS | self::EXT_FATAL) : 0;
self::$customVars['xhpv'] = 'xhp-' . phpversion('xhprof');
} else if (function_exists('uprofiler_enable')) {
self::$extensionPrefix = 'uprofiler';
self::$customVars['xhpv'] = 'up-' . phpversion('uprofiler');
} else {
return;
}
}

Expand Down

0 comments on commit 67cfc28

Please sign in to comment.