Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-27481 profiling - prevent data to be sent to DB before it is avai…

…lable
  • Loading branch information...
commit 68fabb5c7eae858ee1034be610f0403b736befcc 1 parent de58499
Eloy Lafuente (stronk7) stronk7 authored

Showing 1 changed file with 9 additions and 1 deletion. Show diff stats Hide diff stats

  1. +9 1 lib/xhprof/xhprof_moodle.php
10 lib/xhprof/xhprof_moodle.php
@@ -152,7 +152,7 @@ function profiling_start() {
152 152 * Stop profiling, gathering results and storing them
153 153 */
154 154 function profiling_stop() {
155   - global $CFG, $SCRIPT;
  155 + global $CFG, $DB, $SCRIPT;
156 156
157 157 // If profiling isn't available, nothing to stop
158 158 if (!extension_loaded('xhprof') || !function_exists('xhprof_enable')) {
@@ -176,6 +176,14 @@ function profiling_stop() {
176 176 profiling_is_running(false);
177 177 $data = xhprof_disable();
178 178
  179 + // We only save the run after ensuring the DB table exists
  180 + // (this prevents problems with profiling runs enabled in
  181 + // config.php before Moodle is installed. Rare but...
  182 + $tables = $DB->get_tables();
  183 + if (!in_array('profiling', $tables)) {
  184 + return false;
  185 + }
  186 +
179 187 $run = new moodle_xhprofrun();
180 188 $run->prepare_run($script);
181 189 $runid = $run->save_run($data, null);

0 comments on commit 68fabb5

Please sign in to comment.
Something went wrong with that request. Please try again.