multidimension-al / phpbbauth

A Mediawiki extension for phpBB authentication using Auth_remoteuser.
MIT License
5 stars 5 forks source link

breaks upon update to MediaWIki 1.39 #12

Closed MedicineStorm closed 1 year ago

MedicineStorm commented 1 year ago

I love this extension. Unfortunately, it stopped working when I updated from MediaWiki 1.38 to 1.39: PHP Deprecated: Use of PersonalUrls hook (used in PhpbbAuthHooks::onPersonalUrls) was deprecated in MediaWiki 1.39. [Called from MediaWiki\HookContainer\HookContainer::run in ./includes/HookContainer/HookContainer.php at line 137] in ./includes/debug/MWDebug.php on line 381 and also PHP Fatal error: Declaration of Wikimedia\Services\ServiceContainer::get(string $name) must be compatible with Psr\Container\ContainerInterface::get($id) in ./vendor/wikimedia/services/src/ServiceContainer.php on line 418 I'm willing to help fix it... though I may need help helping given my limited knowledge of how it operates. :(

ajquick commented 1 year ago

I'll see if I can find time to look at it. It probably won't require too much work.

One of those errors could probably be suppressed depending on your PHP error reporting level.

On Thu, Mar 2, 2023, 12:03 PM Medicine Storm @.***> wrote:

I love this extension. Unfortunately, it stopped working when I updated from MediaWiki 1.38 to 1.39: PHP Deprecated: Use of PersonalUrls hook (used in PhpbbAuthHooks::onPersonalUrls) was deprecated in MediaWiki 1.39. [Called from MediaWiki\HookContainer\HookContainer::run in ./includes/HookContainer/HookContainer.php at line 137] in ./includes/debug/MWDebug.php on line 381 and also PHP Fatal error: Declaration of Wikimedia\Services\ServiceContainer::get(string $name) must be compatible with Psr\Container\ContainerInterface::get($id) in ./vendor/wikimedia/services/src/ServiceContainer.php on line 418 I'm willing to help fix it... though I may need help helping given my limited knowledge of how it operates. :(

— Reply to this email directly, view it on GitHub https://github.com/multidimension-al/phpbbauth/issues/12, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSIOS3WY6HPSOHZO422I5TW2DVH3ANCNFSM6AAAAAAVNYJEB4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

MedicineStorm commented 1 year ago

The "deprecated" one, sure, but I'm guessing that will bite me later when onPersonalURLs becomes completely nonfunctional next WM version. I'll see if I can figure out the equivalent code for onSkinTemplateNavigation_Universal.

If you do find the time I'd love you for it. Do you have a Ko-Fi account or something? Thanks for taking the time to reply.

MedicineStorm commented 1 year ago

Ok, disregard that PHP Fatal error. Pretty sure it was an oversight when the mediawiki team was adding type hinting which prevents mixed type variables being passed: https://gerrit.wikimedia.org/r/c/mediawiki/libs/Services/+/818406/3/src/ServiceContainer.php Seems like an easy fix to remove the type hinting from the ServiceContainer::get() function.

Still no idea how to replace deprecated PersonalUrls though...

ajquick commented 1 year ago

I just spent a decent amount of time trying to figure out the onSkinTemplateNavigation_Universal.

For whatever reason I wasn't able to crack it. I may recommend using this newer phpBB plugin which leverages the actively updated extension, pluggable auth instead of remote_auth which isn't actively updated.

https://www.mediawiki.org/wiki/Extension:PluggableAuth https://www.mediawiki.org/wiki/Extension:PHPBB_Auth

MedicineStorm commented 1 year ago

Thanks, but I've tried that one already. It doesn't do single sign-on: https://github.com/Digitalroot-Technologies/MediaWiki_PHPBB_Auth/discussions/62

ajquick commented 1 year ago

Oh. I didn't realize it wasn't capable of automatically logging in.

ajquick commented 1 year ago

Figured it out. See the updated code and give it a try.

extension.json

"Hooks": {
    "SkinTemplateNavigation::Universal": "PhpbbAuthHooks::onSkinTemplateNavigationUniversal"
},

PhpbbAuthHooks.php

public static function onSkinTemplateNavigationUniversal($skinTemplate, &$links){
    global $wgPhpbbAuthAbsolutePath, $wgServer;

    if( array_key_exists( 'user-menu', $links ) ){

        if ( array_key_exists( 'login', $links['user-menu'] ) ) {
            $links['user-menu']['login']['href'] = $wgPhpbbAuthAbsolutePath . 'ucp.php?mode=login&redirect=' . urlencode( $wgServer . $_SERVER[ 'REQUEST_URI' ] );
        }

        if ( array_key_exists( 'anonlogin', $links['user-menu'] ) ) {
            $links['user-menu']['anonlogin']['href'] = $wgPhpbbAuthAbsolutePath . 'ucp.php?mode=login&redirect=' . urlencode( $wgServer . $_SERVER[ 'REQUEST_URI' ] );
        }

    }

}

Give it a test and then I'll release it.

MedicineStorm commented 1 year ago

Woo! That appears to work. ...well, it isn't generating a deprecated error, but it looks like .\extensions\Auth_remoteuser\src\UserNameSessionProvider.php still uses PersonalUrls. However, your code above shows the equivalence between the two. I'll bet Auth_remoteuser can be updated in a similar way. Thank you!