Page MenuHomePhabricator

Incompatible `MediaWikiAuth::setLogger` declaration
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue

Trying to login on a self-hosted MediaWiki site, after the login process, the site become unreachable.

What happens?

The debug log shows the following details:

[PluggableAuth] Getting PluggableAuth instance
[PluggableAuth] Plugin name: WSOAuth
[exception] [0658d403eb67ddafb7ac738b] /dt/index.php/Special:Version   PHP Fatal Error from line 68 of /var/www/html/dt/extensions/WSOAuth/src/AuthenticationProvider/MediaWikiAuth.php: Declaration of WSOAuth\AuthenticationProvider\MediaWikiAuth::setLogger(Psr\Log\LoggerInterface $logger) must be compatible with WSOAuth\AuthenticationProvider\AuthProvider::setLogger(Psr\Log\LoggerInterface $logger): void
#0 [internal function]: MWExceptionHandler::handleFatalError()
#1 {main}

What should have happened instead?

Login process should finish properly

Software version

ProductVersion
MediaWiki1.43.1
PHP8.3.6 (apache2handler)
ICU74.2
MariaDB10.11.13-MariaDB-0ubuntu0.24.04.1
PluggableAuth7.5.0 (825c652)
WSOAuth9.0.0 (4820686)

Conclusions

As far as I understand, the problem is in the definition of the function:

/**
 * @inheritDoc
 */
public function setLogger( LoggerInterface $logger ) {
        parent::setLogger( $logger );
        $this->client->setLogger( $logger );
}

the definition should be:

public function setLogger( LoggerInterface $logger ): void {

instead.

I tried to manually apply this modification to my installation and it started working.

Event Timeline

Change #1176813 had a related patch set uploaded (by Luca Mauri; author: Luca Mauri):

[mediawiki/extensions/WSOAuth@master] component: setLogger function

https://gerrit.wikimedia.org/r/1176813

Change #1176813 abandoned by Luca Mauri:

[mediawiki/extensions/WSOAuth@master] component: setLogger function

Reason:

Wrong branch selected

https://gerrit.wikimedia.org/r/1176813

Change #1176815 had a related patch set uploaded (by Luca Mauri; author: Luca Mauri):

[mediawiki/extensions/WSOAuth@REL1_43] component: setLogger function

https://gerrit.wikimedia.org/r/1176815

Change #1176815 had a related patch set uploaded (by Luca Mauri; author: Luca Mauri):

[mediawiki/extensions/WSOAuth@REL1_43] component: setLogger function

https://gerrit.wikimedia.org/r/1176815

As an additional observation, it seems the declaration is properly written in the master branch, but is wrong both in REL1_43 (version 9.0.0) and REL1_44 (version 9.0.1).
I proposed a patch for REL1_43: provided this is accepted, another identical one should be mode for REL1_44.
I haven't investigated versions between 1.35 and 1.44.

The master branch was updated with https://gerrit.wikimedia.org/r/c/mediawiki/extensions/WSOAuth/+/1161037 / d14730a712db8123cb4ffd07575b8241c3fad382

It aims to make it compatible with psr/log 3.0.0. mediawiki/core itselfs installs psr/log 1.1.4.

While MediaWikiAuth has it own setLogger, the parent class AuthProvider is using the LoggerAwareTrait. The trait is from the newest psr/log version and includes the return type, while the own class in REL1_43 does not have it, that is a fatal.

Running composer update from within WSOAuth folder installs 3.0.2, it is allowed by:

# composer why psr/log
mediawiki/oauthclient 2.3.0 requires psr/log (^1.0||^2.0||^3.0)

It seems your installation has two vendor folder and it autoloads psr/log now from the wrong (from the extension) and no longer from core.
Maybe the merge plugin helps to avoid this situation in the future: https://www.mediawiki.org/wiki/Composer#Using_composer-merge-plugin

On the other side the composer problems happens often, so backporting the change set seems safe as well.

Change #1177448 had a related patch set uploaded (by Umherirrender; author: Fomafix):

[mediawiki/extensions/WSOAuth@REL1_44] Add return type on setLogger and implement LoggerAwareInterface

https://gerrit.wikimedia.org/r/1177448

Change #1177449 had a related patch set uploaded (by Umherirrender; author: Fomafix):

[mediawiki/extensions/WSOAuth@REL1_43] Add return type on setLogger and implement LoggerAwareInterface

https://gerrit.wikimedia.org/r/1177449

Change #1177449 merged by jenkins-bot:

[mediawiki/extensions/WSOAuth@REL1_43] Add return type on setLogger and implement LoggerAwareInterface

https://gerrit.wikimedia.org/r/1177449

Change #1177448 merged by jenkins-bot:

[mediawiki/extensions/WSOAuth@REL1_44] Add return type on setLogger and implement LoggerAwareInterface

https://gerrit.wikimedia.org/r/1177448

While is task is Invalid, I make it resolved, as a mitigation is backported.

Thanks for your prompt answer.

It seems your installation has two vendor folder and

Yes.
Is this wrong? I am not doing any special configuration to the extension, I simply followed the basic instructions in the extension's page.
By he way, I am using this extension since 2023 and I can confirm the vendor folder is present in the extension's folder even in my "old" 1.39-based MediaWiki installation.

it autoloads psr/log now from the wrong (from the extension) and no longer from core.

I am afraid I am not expert enough to explain why this is happening.

Maybe the merge plugin helps to avoid this situation in the future: https://www.mediawiki.org/wiki/Composer#Using_composer-merge-plugin

I can confirm you that I do user merge-plugin, so it does not avoid this situation.