Merge branch 'ent-2753-meter-profiler-en-el-docker' into 'develop'

Added profiller to docker

See merge request artica/pandorafms!1966

Former-commit-id: 24ade418bbc05cc6a40ee6f988b53eb648fffec5
This commit is contained in:
fermin 2019-01-14 14:59:50 +01:00
commit 24260cea34
3 changed files with 63 additions and 0 deletions

View File

@ -14,6 +14,15 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Enable profiler for testing
if (!defined("__PAN_XHPROF__")) define ("__PAN_XHPROF__", 0);
if (__PAN_XHPROF__ === 1) {
if (function_exists('tideways_xhprof_enable')) {
tideways_xhprof_enable();
}
}
if ((! file_exists("include/config.php")) || (! is_readable("include/config.php"))) {
exit;
}
@ -88,4 +97,8 @@ if (file_exists ($page)) {
else {
echo '<br /><b class="error">Sorry! I can\'t find the page '.$page.'!</b>';
}
if (__PAN_XHPROF__ === 1) {
pandora_xhprof_display_result("ajax", "console");
}
?>

View File

@ -3400,5 +3400,39 @@ function validate_csrf_code() {
function generate_hash_to_api(){
hash('sha256', db_get_value ('value', 'tupdate_settings', '`key`', 'customer_key'));
}
/**
* Disable the profiller and display de result
*
* @param string Key to identify the profiler run.
* @param string Way to display the result
* "link" (default): Click into word "Performance" to display the profilling info.
* "console": Display with a message in pandora_console.log.
*/
function pandora_xhprof_display_result($key = "", $method = "link") {
// Check if function exists
if (!function_exists('tideways_xhprof_disable')) {
error_log("Cannot find tideways_xhprof_disable function");
return;
}
$run_id = uniqid();
$data = tideways_xhprof_disable();
$source = "pandora_$key";
file_put_contents(
sys_get_temp_dir() . "/" . $run_id . ".$source.xhprof",
serialize($data)
);
$new_url = "http://{$_SERVER['HTTP_HOST']}/profiler/index.php?run={$run_id}&source={$source}";
switch($method) {
case "console":
error_log("'{$new_url}'");
case "link":
default:
echo "<a href='{$new_url}' target='_new'>Performance</a>\n";
break;
}
}
?>

View File

@ -14,6 +14,17 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Enable profiler for testing
if (!defined("__PAN_XHPROF__")) define ("__PAN_XHPROF__", 0);
if (__PAN_XHPROF__ === 1) {
if (function_exists('tideways_xhprof_enable')) {
tideways_xhprof_enable();
} else {
error_log("Cannot find tideways_xhprof_enable function");
}
}
//Set character encoding to UTF-8 - fixes a lot of multibyte character headaches
if (function_exists ('mb_internal_encoding')) {
mb_internal_encoding ("UTF-8");
@ -1277,3 +1288,8 @@ require('include/php_to_js_values.php');
*/
}
</script>
<?php
if (__PAN_XHPROF__ === 1) {
pandora_xhprof_display_result("node_index");
}
?>