From c4422bdbb553bc3ff89a7fdfa3ceabe7cd5a49c6 Mon Sep 17 00:00:00 2001 From: Michael Bemmerl Date: Wed, 27 May 2020 21:08:06 +0000 Subject: [PATCH] [Core] Fix notice of undefined offset when in detached HEAD state. (#1569) --- lib/Configuration.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Configuration.php b/lib/Configuration.php index 76a34aff..d46a6091 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -244,9 +244,13 @@ final class Configuration { if(@is_readable($headFile)) { $revisionHashFile = '.git/' . substr(file_get_contents($headFile), 5, -1); - $branchName = explode('/', $revisionHashFile)[3]; - if(file_exists($revisionHashFile)) { - return 'git.' . $branchName . '.' . substr(file_get_contents($revisionHashFile), 0, 7); + $parts = explode('/', $revisionHashFile); + + if(isset($parts[3])) { + $branchName = $parts[3]; + if(file_exists($revisionHashFile)) { + return 'git.' . $branchName . '.' . substr(file_get_contents($revisionHashFile), 0, 7); + } } }