Skip to content

Commit 19993fa

Browse files
authored
Refactor user info retrieval methods
fix warnings: E_WARNING: Trying to access array offset on null/storage/lib/plugins/gitbacked/action/editcommit.php(96) E_WARNING: Trying to access array offset on null/storage/lib/plugins/gitbacked/action/editcommit.php(100)
1 parent 4075d34 commit 19993fa

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

action/editcommit.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,19 @@ private function commitFile($filePath, $message)
117117
}
118118
}
119119

120-
private function getAuthor()
121-
{
122-
return $GLOBALS['USERINFO']['name'];
120+
private function getUserInfo($key) {
121+
if (isset($GLOBALS['USERINFO'][$key])) {
122+
return $GLOBALS['USERINFO'][$key];
123+
}
124+
return '';
123125
}
124-
125-
private function getAuthorMail()
126-
{
127-
return $GLOBALS['USERINFO']['mail'];
126+
127+
private function getAuthor() {
128+
return $this->getUserInfo('name');
129+
}
130+
131+
private function getAuthorMail() {
132+
return $this->getUserInfo('mail');
128133
}
129134

130135
private function computeLocalPath()

0 commit comments

Comments
 (0)