Skip to content

Commit c4422bd

Browse files
authored
[Core] Fix notice of undefined offset when in detached HEAD state. (RSS-Bridge#1569)
1 parent a1dd98f commit c4422bd

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/Configuration.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,13 @@ public static function getVersion() {
244244
if(@is_readable($headFile)) {
245245

246246
$revisionHashFile = '.git/' . substr(file_get_contents($headFile), 5, -1);
247-
$branchName = explode('/', $revisionHashFile)[3];
248-
if(file_exists($revisionHashFile)) {
249-
return 'git.' . $branchName . '.' . substr(file_get_contents($revisionHashFile), 0, 7);
247+
$parts = explode('/', $revisionHashFile);
248+
249+
if(isset($parts[3])) {
250+
$branchName = $parts[3];
251+
if(file_exists($revisionHashFile)) {
252+
return 'git.' . $branchName . '.' . substr(file_get_contents($revisionHashFile), 0, 7);
253+
}
250254
}
251255
}
252256

0 commit comments

Comments
 (0)