From 6919693cd60ff3b12d6e09df274803fee98eee05 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Fri, 22 Feb 2013 02:05:04 +0100 Subject: [PATCH] MDL-38161 Upgrade xhprof to 02-2013 commits Note this continues being version 0.9.2 and only a few changes have landed since 3y ago. (the important stuff is in the xhprof extension, not in this UI package using it) --- lib/xhprof/readme_moodle.txt | 8 +++++--- lib/xhprof/xhprof_html/callgraph.php | 11 +++++------ lib/xhprof/xhprof_html/css/xhprof.css | 8 +++----- lib/xhprof/xhprof_html/index.php | 10 +++++----- lib/xhprof/xhprof_html/jquery/indicator.gif | Bin 1553 -> 1435 bytes lib/xhprof/xhprof_html/typeahead.php | 11 +++++------ .../xhprof_lib/utils/callgraph_utils.php | 10 +++++++--- lib/xhprof/xhprof_lib/utils/xhprof_runs.php | 4 +++- 8 files changed, 33 insertions(+), 29 deletions(-) diff --git a/lib/xhprof/readme_moodle.txt b/lib/xhprof/readme_moodle.txt index 6168abd7b7f..f732a368f5b 100644 --- a/lib/xhprof/readme_moodle.txt +++ b/lib/xhprof/readme_moodle.txt @@ -1,17 +1,19 @@ Description of XHProf 0.9.2 library/viewer import into Moodle -Removed: +Removed (commit #1): + * .arcconfig - Definitions for arcanist/phabricator removed completely + * composer.json - Composer's definition removed completely * examples - examples dir removed completely * extension - extension dir removed completely * package.xml - PECL package definition removed completely * xhprof_html/docs - documentation dir removed completely -Added: +Added (commit #2 - always taken from current moodle.git master): * index.html - prevent directory browsing on misconfigured servers * xhprof_moodle.php - containing all the stuff needed to run the xhprof profiler within Moodle * readme_moodle.txt - this file ;-) -Our changes: Look for "moodle" in code +Our changes: Look for "moodle" in code (commit #3 - always mimic from current moodle.git master): * xhprof_html/index.php ----| * xhprof_html/callgraph.php -|=> Changed to use own DB iXHProfRuns implementation (moodle_xhprofrun) * xhprof_html/typeahead.php -| diff --git a/lib/xhprof/xhprof_html/callgraph.php b/lib/xhprof/xhprof_html/callgraph.php index 9f7acabac0e..a315dbcefdf 100644 --- a/lib/xhprof/xhprof_html/callgraph.php +++ b/lib/xhprof/xhprof_html/callgraph.php @@ -29,12 +29,12 @@ * @author Changhao Jiang (cjiang@facebook.com) */ -// start moodle modification: moodleize this script +// Start moodle modification: moodleize this script. require_once(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php'); require_once($CFG->libdir . '/xhprof/xhprof_moodle.php'); require_login(); require_capability('moodle/site:config', context_system::instance()); -// end moodle modification +// End moodle modification. // by default assume that xhprof_html & xhprof_lib directories // are at the same level. @@ -85,11 +85,10 @@ if (!array_key_exists($type, $xhprof_legal_image_types)) { $type = $params['type'][1]; // default image type. } -// start moodle modification: use own XHProfRuns implementation -//$xhprof_runs_impl = new XHProfRuns_Default(); -require_once($GLOBALS['XHPROF_LIB_ROOT'].'/../xhprof_moodle.php'); +// Start moodle modification: use own XHProfRuns implementation. +// $xhprof_runs_impl = new XHProfRuns_Default(); $xhprof_runs_impl = new moodle_xhprofrun(); -// end moodle modification +// End moodle modification. if (!empty($run)) { // single run call graph image generation diff --git a/lib/xhprof/xhprof_html/css/xhprof.css b/lib/xhprof/xhprof_html/css/xhprof.css index 712fc7754b9..fc727d9d789 100644 --- a/lib/xhprof/xhprof_html/css/xhprof.css +++ b/lib/xhprof/xhprof_html/css/xhprof.css @@ -13,13 +13,11 @@ * limitations under the License. */ -/* start moodle modification: add basic, smaller, font specs */ +/* Start moodle modification: add basic, smaller, font specs */ body, p, table, li { - font: normal normal normal 13px/1.231 arial, helvetica, clean, sans-serif; + font: normal normal normal 13px/1.231 arial, helvetica, clean, sans-serif; } - -/* end moodle modification */ - +/* End moodle modification */ td.sorted { color:#0000FF; diff --git a/lib/xhprof/xhprof_html/index.php b/lib/xhprof/xhprof_html/index.php index e032916e175..4748424500e 100644 --- a/lib/xhprof/xhprof_html/index.php +++ b/lib/xhprof/xhprof_html/index.php @@ -31,12 +31,12 @@ // Changhao Jiang // -// start moodle modification: moodleize this script +// Start moodle modification: moodleize this script. require_once(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php'); require_once($CFG->libdir . '/xhprof/xhprof_moodle.php'); require_login(); require_capability('moodle/site:config', context_system::instance()); -// end moodle modification +// End moodle modification. // by default assume that xhprof_html & xhprof_lib directories // are at the same level. @@ -87,10 +87,10 @@ $vbbar = ' class="vbbar"'; $vrbar = ' class="vrbar"'; $vgbar = ' class="vgbar"'; -// start moodle modification: use own XHProfRuns implementation -//$xhprof_runs_impl = new XHProfRuns_Default() +// Start moodle modification: use own XHProfRuns implementation. +// $xhprof_runs_impl = new XHProfRuns_Default(); $xhprof_runs_impl = new moodle_xhprofrun(); -// end moodle modification +// End moodle modification. displayXHProfReport($xhprof_runs_impl, $params, $source, $run, $wts, $symbol, $sort, $run1, $run2); diff --git a/lib/xhprof/xhprof_html/jquery/indicator.gif b/lib/xhprof/xhprof_html/jquery/indicator.gif index 085ccaecaf5fa5c34bc14cd2c2ed5cbbd8e25dcb..9c26a717c1b8cb7bb0d6a447115be1ddacf7f206 100644 GIT binary patch literal 1435 zcmZvbe^AnQ7{@^ctJUr8?Pjz2(W6IMSy@ab6D&6Y z<4=N2RJb`)AQ!Do;08d;rDrf23&$+=L%#u0ap@RCwc zYV;n9tt+if2P`<^-MkP27DI*#11e(!FwwQapgb0UBFd{U0y$e z&N@9>tfzrs!e@h)>NoGU@CX0kvamHF|4~GI2LQ0rr>J)*n66t&AuDZYf>YaDD4K|! z1Y(m#+u*=mvr%6sF;)-&;qySyT@acOtWDq!AM6Y?6n|UYcbRH*%#dh+0Df<`vN7Ik z+J->4hn%)pKf0Ous=>d{TS4`tE;*mj z{QhwMT!Vc6M2M@d!LEoZ!H>?~WWen3ZDE#a0T443+g9Y|beBDm{z~iLuEj0sKNh<7 zyN+dK68X((vU8D4;cltAmkQ)4jL1(+kbm+rF}ufHzX03x#hBwq1}z-Sd3NK3c}7cI z;M=Gcvs4u>yur1i`H&(v)L_W$vl4m7(9xkKiPUqUj>2ybnj;-g}|>$!RcLX#cMWFDSNN0KbixF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ib/xhprof/xhprof_html/typeahead.php b/lib/xhprof/xhprof_html/typeahead.php index 78a753792b9..0cebba7b9fe 100644 --- a/lib/xhprof/xhprof_html/typeahead.php +++ b/lib/xhprof/xhprof_html/typeahead.php @@ -21,12 +21,12 @@ * Changhao Jiang */ -// start moodle modification: moodleize this script +// Start moodle modification: moodleize this script. require_once(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php'); require_once($CFG->libdir . '/xhprof/xhprof_moodle.php'); require_login(); require_capability('moodle/site:config', context_system::instance()); -// end moodle modification +// End moodle modification. // by default assume that xhprof_html & xhprof_lib directories // are at the same level. @@ -34,10 +34,9 @@ $GLOBALS['XHPROF_LIB_ROOT'] = dirname(__FILE__) . '/../xhprof_lib'; require_once $GLOBALS['XHPROF_LIB_ROOT'].'/display/xhprof.php'; -// start moodle modification: use own XHProfRuns implementation -//$xhprof_runs_impl = new XHProfRuns_Default(); -require_once($GLOBALS['XHPROF_LIB_ROOT'].'/../xhprof_moodle.php'); +// Start moodle modification: use own XHProfRuns implementation. +// $xhprof_runs_impl = new XHProfRuns_Default(); $xhprof_runs_impl = new moodle_xhprofrun(); -// end moodle modification +// End moodle modification. require_once $GLOBALS['XHPROF_LIB_ROOT'].'/display/typeahead_common.php'; diff --git a/lib/xhprof/xhprof_lib/utils/callgraph_utils.php b/lib/xhprof/xhprof_lib/utils/callgraph_utils.php index 203ecee0feb..93ccaa63daa 100644 --- a/lib/xhprof/xhprof_lib/utils/callgraph_utils.php +++ b/lib/xhprof/xhprof_lib/utils/callgraph_utils.php @@ -25,6 +25,7 @@ $xhprof_legal_image_types = array( "jpg" => 1, "gif" => 1, "png" => 1, + "svg" => 1, // support scalable vector graphic "ps" => 1, ); @@ -68,6 +69,9 @@ function xhprof_generate_mime_header($type, $length) { case 'png': $mime = 'image/png'; break; + case 'svg': + $mime = 'image/svg+xml'; // content type for scalable vector graphic + break; case 'ps': $mime = 'application/postscript'; default: @@ -103,11 +107,11 @@ function xhprof_generate_image_by_dot($dot_script, $type) { 2 => array("pipe", "w") ); - // start moodle modification: use $CFG->pathtodot for executing this - //$cmd = " dot -T".$type; + // Start moodle modification: use $CFG->pathtodot for executing this. + // $cmd = " dot -T".$type; global $CFG; $cmd = (!empty($CFG->pathtodot) ? $CFG->pathtodot : 'dot') . ' -T' . $type; - // end moodle modification + // End moodle modification. $process = proc_open($cmd, $descriptorspec, $pipes, "/tmp", array()); if (is_resource($process)) { diff --git a/lib/xhprof/xhprof_lib/utils/xhprof_runs.php b/lib/xhprof/xhprof_lib/utils/xhprof_runs.php index c12f77cb26c..cde5ff556bf 100644 --- a/lib/xhprof/xhprof_lib/utils/xhprof_runs.php +++ b/lib/xhprof/xhprof_lib/utils/xhprof_runs.php @@ -149,7 +149,9 @@ class XHProfRuns_Default implements iXHProfRuns { function list_runs() { if (is_dir($this->dir)) { echo "
Existing runs:\n
    \n"; - foreach (glob("{$this->dir}/*.{$this->suffix}") as $file) { + $files = glob("{$this->dir}/*.{$this->suffix}"); + usort($files, create_function('$a,$b', 'return filemtime($b) - filemtime($a);')); + foreach ($files as $file) { list($run,$source) = explode('.', basename($file)); echo '