Permalink
Browse files

Merge branch 'prevent_profiling_before_install' of git://github.com/s…

…tronk7/moodle
  • Loading branch information...
2 parents 3efd551 + 68fabb5 commit 62ff4fe30b228f31a48973292b475ea55f329ef1 Sam Hemelryk committed May 16, 2011
Showing with 9 additions and 1 deletion.
  1. +9 −1 lib/xhprof/xhprof_moodle.php
@@ -152,7 +152,7 @@ function profiling_start() {
* Stop profiling, gathering results and storing them
*/
function profiling_stop() {
- global $CFG, $SCRIPT;
+ global $CFG, $DB, $SCRIPT;
// If profiling isn't available, nothing to stop
if (!extension_loaded('xhprof') || !function_exists('xhprof_enable')) {
@@ -176,6 +176,14 @@ function profiling_stop() {
profiling_is_running(false);
$data = xhprof_disable();
+ // We only save the run after ensuring the DB table exists
+ // (this prevents problems with profiling runs enabled in
+ // config.php before Moodle is installed. Rare but...
+ $tables = $DB->get_tables();
+ if (!in_array('profiling', $tables)) {
+ return false;
+ }
+
$run = new moodle_xhprofrun();
$run->prepare_run($script);
$runid = $run->save_run($data, null);

0 comments on commit 62ff4fe

Please sign in to comment.