Skip to content

Fix undefined array key REMOTE_USER warning in init()#13

Open
magicsunday wants to merge 1 commit intovisol:mainfrom
magicsunday:fix/undefined-remote-user-key
Open

Fix undefined array key REMOTE_USER warning in init()#13
magicsunday wants to merge 1 commit intovisol:mainfrom
magicsunday:fix/undefined-remote-user-key

Conversation

@magicsunday
Copy link

Summary

  • Fix PHP Warning Undefined array key "REMOTE_USER" in ShibbolethAuthenticationService::init() when no Shibboleth session is active

Problem

Every non-Shibboleth request to the TYPO3 backend triggers:

PHP Warning: Undefined array key "REMOTE_USER" in
Classes/Typo3/Service/ShibbolethAuthenticationService.php line 53

Solution

Use the null coalescing operator to default $this->remoteUser to null when $_SERVER['REMOTE_USER'] is not set. This is safe because:

  • The property is already typed as ?string
  • All usages check for null/empty via empty($this->remoteUser)

Fixes #12

When no Shibboleth session is active, $_SERVER['REMOTE_USER'] is not
set, causing a PHP Warning on every backend request.

Use the null coalescing operator to default to null, which is already
supported by the ?string property type and handled by all callers via
empty() checks.

Fixes visol#12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PHP Warning: Undefined array key REMOTE_USER in ShibbolethAuthenticationService::init()

1 participant