diff --git a/xhprof_lib/utils/xhprof_runs.php b/xhprof_lib/utils/xhprof_runs.php index 2a22a5dc..6aa5bf7e 100644 --- a/xhprof_lib/utils/xhprof_runs.php +++ b/xhprof_lib/utils/xhprof_runs.php @@ -78,6 +78,15 @@ private function file_name($run_id, $type) { $file = "$run_id.$type." . $this->suffix; + // work-around to avoid too long file names + // inspired by https://github.com/simenbw + $maxLength = 255; + if (strlen($file) > $maxLength) { + $md5 = md5($file); + $suffixLength = strlen($this->suffix) + 1; + $file = substr_replace($file, $md5, $maxLength - (strlen($md5) + $suffixLength), -$suffixLength); + } + if (!empty($this->dir)) { $file = $this->dir . "/" . $file; }