Page MenuHomePhabricator

MobileFrontend throws type error when logging in (PHP 8.1.1)
Closed, ResolvedPublicBUG REPORT

Description

I'm not entirely sure if this is an issue with my set up, or if it is a general issue with the MobileFrontend extension. Whenever I try to log-in on a wiki using MobileFrontend (and CentralAuth if that makes a difference), it throws a type error, but logs me in anyway if I refresh the page.

The error is:

[a011ee98ed48f9654ecbe59c] /wiki/Special:CentralLogin/start?token=redacted
TypeError: Cannot access offset of type string on string

Backtrace:

from /var/www/html/mediawiki1/extensions/MobileFrontend/includes/MobileFrontendHooks.php(960)
#0 /var/www/html/mediawiki1/includes/HookContainer/HookContainer.php(338): MobileFrontendHooks::onCentralAuthLoginRedirectData()
#1 /var/www/html/mediawiki1/includes/HookContainer/HookContainer.php(137): MediaWiki\HookContainer\HookContainer->callLegacyHook()
#2 /var/www/html/mediawiki1/extensions/CentralAuth/includes/Hooks/CentralAuthHookRunner.php(74): MediaWiki\HookContainer\HookContainer->run()
#3 /var/www/html/mediawiki1/extensions/CentralAuth/includes/Special/SpecialCentralLogin.php(223): MediaWiki\Extension\CentralAuth\Hooks\CentralAuthHookRunner->onCentralAuthSilentLoginRedirect()
#4 /var/www/html/mediawiki1/extensions/CentralAuth/includes/Special/SpecialCentralLogin.php(88): MediaWiki\Extension\CentralAuth\Special\SpecialCentralLogin->doLoginStart()
#5 /var/www/html/mediawiki1/includes/specialpage/SpecialPage.php(701): MediaWiki\Extension\CentralAuth\Special\SpecialCentralLogin->execute()
#6 /var/www/html/mediawiki1/includes/specialpage/SpecialPageFactory.php(1428): SpecialPage->run()
#7 /var/www/html/mediawiki1/includes/MediaWiki.php(316): MediaWiki\SpecialPage\SpecialPageFactory->executePath()
#8 /var/www/html/mediawiki1/includes/MediaWiki.php(904): MediaWiki->performRequest()
#9 /var/www/html/mediawiki1/includes/MediaWiki.php(562): MediaWiki->main()#10 /var/www/html/mediawiki1/index.php(49): MediaWiki->run()
#11 /var/www/html/mediawiki1/index.php(45): wfIndexMain()
#12 {main}

This is using MediaWiki 1.39.1 and PHP 8.1.18, both MobileFrontend and CentralAuth have been updated with the REL1_39 branches, but this doesn't solve the issue.

Event Timeline

Reedy added a project: MW-1.39-release.
Reedy subscribed.

Line 960 is a MediaWiki-extensions-CentralAuth hook subscriber...

It's entirely possible this is fixed in MW-1.40-release or master, but not backported...

Change 925006 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/extensions/CentralAuth@master] Fix hook runner for CentralAuthSilentLoginRedirect

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

Change 925006 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] Fix hook runner for CentralAuthSilentLoginRedirect

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

Change 925006 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/extensions/CentralAuth@master] Fix hook runner for CentralAuthSilentLoginRedirect

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

Confirmed that this fixes the issue. Thank you for your quck response! :)

Change 924945 had a related patch set uploaded (by Reedy; author: Umherirrender):

[mediawiki/extensions/CentralAuth@REL1_40] Fix hook runner for CentralAuthSilentLoginRedirect

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

Change 925026 had a related patch set uploaded (by Reedy; author: Umherirrender):

[mediawiki/extensions/CentralAuth@REL1_39] Fix hook runner for CentralAuthSilentLoginRedirect

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

Change 924945 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@REL1_40] Fix hook runner for CentralAuthSilentLoginRedirect

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

Change 925026 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@REL1_39] Fix hook runner for CentralAuthSilentLoginRedirect

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

Reedy assigned this task to Umherirrender.

Change 925006 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/extensions/CentralAuth@master] Fix hook runner for CentralAuthSilentLoginRedirect

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

Confirmed that this fixes the issue. Thank you for your quick response! :)

This just throw the error under php8.1 as the hook arguments are from different types for the both hook name mixed up in the hook runner. So we are a all bit lucky about this mistake one year ago and the finding here.
I have uploaded some patch set to improve testing for this (https://gerrit.wikimedia.org/r/c/mediawiki/core/+/925008 and https://gerrit.wikimedia.org/r/c/mediawiki/extensions/CentralAuth/+/925009) hopefully finding this issue early in the future.

It seems this can only happen when using Special:UserLogin on login wiki (set by $wgCentralAuthLoginWiki), that does not happen on wmf wikis.

Thanks for reporting!