While using the code:
'event_listeners' => [
[
\League\OAuth2\Server\RequestEvent::USER_AUTHENTICATION_FAILED,
\NuclearAuth\Listener\UserAuthenticationFailedListener::class,
],
],
from “Introduction - mezzio-authentication-oauth2 - Laminas Docs” in PHP 7.4 works fine, but in PHP 8.1it throws the following error: “array_merge() does not accept unknown named parameters”.
If I don’t use the that specific part of the code, everything works correctly.
More info:
The error actually cames from “league/oauth2-server” but because it’s “Mezzio-authentication-oauth2” implementation…
The error is only thrown when the user authentication fails and the listener should kick in…
Welcome to the forum
Does both packages support php 8.1?
Whats line 159 of Emitter.php?
I ask whats line 159 because I have tried to find it in a github repo with zero luck.
The Emitter.php is from “league/event” wich is required by “league/oauth2-server”. The file can be found at event/Emitter.php at 2.2.0 · thephpleague/event · GitHub .
The “league/oauth2-server” requires a “league/event”: “^2.2”. The 2.2 version of “league/event” is the one installed.
The version of “league/oauth2-server” is 8.5.1. As of version of 8.5.0, PHP 8.1 is supported.
Thanks in advance.
What is the content of this file?
I think this is your problem but I’m not sure where its coming from.
call_user_func_array('array_merge', [
'some_key' => ['value', 'another_value'],
'some_other_key' => ['this_value', 'that_value']
]);
The enclosing [ ]
is possibly your issue. So its possibly the structure of the $listeners array that is being passed.
Created an issue in Mezzio Authentication OAuth2 repo better describing the situation and possible ways to mitigate or resolve it.
https://github.com/mezzio/mezzio-authentication-oauth2/issues/63
A simple solution would be to always define a priority level in each listener. So this:
'event_listeners' => [
[
\League\OAuth2\Server\RequestEvent::USER_AUTHENTICATION_FAILED,
\NuclearAuth\Listener\UserAuthenticationFailedListener::class,
],
],
would became this:
'event_listeners' => [
[
\League\OAuth2\Server\RequestEvent::USER_AUTHENTICATION_FAILED,
\NuclearAuth\Listener\UserAuthenticationFailedListener::class,
\League\Event\EmitterInterface::P_HIGH
]
]