You are here

public function XHProfRunsFile::get_run in XHProf 7

Same name and namespace in other branches
  1. 6 XHProfRunsFile.inc \XHProfRunsFile::get_run()

File

./XHProfRunsFile.inc, line 56
Definition of XHProfRunsFile.

Class

XHProfRunsFile
XHProfRuns_Default is the default implementation of the iXHProfRuns interface for saving/fetching XHProf runs.

Code

public function get_run($run_id, $type, &$run_desc) {
  if (!is_dir($this->dir) || !is_writable($this->dir)) {

    // If the runs directory is not found or writable.
    drupal_set_message(t('XHProf could not find the runs directory "%directory".', array(
      '%directory' => $this->dir,
    )), 'error');
    $run_desc = "Invalid runs directory = {$this->dir}";
    return NULL;
  }
  $file_name = $this
    ->file_name($run_id, $type);
  if (!file_exists($file_name)) {
    watchdog("xhprof", "Could not find file %file_name", array(
      '%file_name' => $file_name,
    ));
    $run_desc = "Invalid Run Id = {$run_id}";
    return NULL;
  }
  $contents = file_get_contents($file_name);
  $run_desc = "XHProf Run (Namespace={$type})";
  return unserialize($contents);
}