From e2d0f140a713cbd91023e324321e57555b24bc18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hagen=20H=C3=BCbel?= Date: Fri, 16 Oct 2015 12:10:47 +0200 Subject: [PATCH] work-around to avoid too long file names --- xhprof_lib/utils/xhprof_runs.php | 9 +++++++++ 1 file changed, 9 insertions(+) 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; }