When sending an unauthenticated REST request this plugins generates the following two PHP notices:
PHP Notice: Undefined index: HTTP_AUTHORIZATION in /wp-content/plugins/jwt-authentication-for-wp-rest-api/public/class-jwt-auth-public.php on line 222
PHP Notice: Undefined index: REDIRECT_HTTP_AUTHORIZATION in /wp-content/plugins/jwt-authentication-for-wp-rest-api/public/class-jwt-auth-public.php on line 225
This is due to accessing $_SERVER['HTTP_AUTHORIZATION'] and $_SERVER['REDIRECT_HTTP_AUTHORIZATION'] without using isset() first. This PR resolves this by first using empty() in order to check if the headers are set and not empty.
Steps to reproduce the issue
Enable WP_DEBUG.
Send an unauthenticated request to for example /wp-json/, for example by just visiting that endpoint in the URL.
When sending an unauthenticated REST request this plugins generates the following two PHP notices:
This is due to accessing
$_SERVER['HTTP_AUTHORIZATION']
and$_SERVER['REDIRECT_HTTP_AUTHORIZATION']
without usingisset()
first. This PR resolves this by first usingempty()
in order to check if the headers are set and not empty.Steps to reproduce the issue
WP_DEBUG
./wp-json/
, for example by just visiting that endpoint in the URL.Undefined index
notices.With the changes in this PR this is resolved.