Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work with SMF 2.1.2 and MediaWiki 1.38.2 #20

Closed
strange-creature opened this issue Aug 1, 2022 · 18 comments · Fixed by #21
Closed

Does not work with SMF 2.1.2 and MediaWiki 1.38.2 #20

strange-creature opened this issue Aug 1, 2022 · 18 comments · Fixed by #21

Comments

@strange-creature
Copy link

On SMF 2.1.2 and MediaWiki 1.38.2 I'm getting this:

[Yuc1b4euz_HcQnDAapAwUAAAAAI] /index.php?title=Main_Page   TypeError: Argument 1 passed to MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider::__construct() must implement interface Wikimedia\Rdbms\ILoadBalancer, array given, called in /home/path1/public_html/site1/extensions/ForumSsoProvider/ForumAuthManager.php on line 26
#0 /home/path1/public_html/site1/extensions/ForumSsoProvider/ForumAuthManager.php(26): MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider->__construct(array)
#1 /home/path1/public_html/site1/vendor/wikimedia/object-factory/src/ObjectFactory.php(247): ForumAuthManager->__construct()
#2 /home/path1/public_html/site1/vendor/wikimedia/object-factory/src/ObjectFactory.php(152): Wikimedia\ObjectFactory\ObjectFactory::getObjectFromSpec(array, array)
#3 /home/path1/public_html/site1/includes/auth/AuthManager.php(2401): Wikimedia\ObjectFactory\ObjectFactory->createObject(array, array)
#4 /home/path1/public_html/site1/includes/auth/AuthManager.php(2446): MediaWiki\Auth\AuthManager->providerArrayFromSpecs(string, array)
#5 /home/path1/public_html/site1/includes/auth/AuthManager.php(1016): MediaWiki\Auth\AuthManager->getPrimaryAuthenticationProviders()
#6 /home/path1/public_html/site1/includes/skins/SkinTemplate.php(620): MediaWiki\Auth\AuthManager->canCreateAccounts()
#7 /home/path1/public_html/site1/includes/skins/SkinTemplate.php(519): SkinTemplate->useCombinedLoginLink()
#8 /home/path1/public_html/site1/includes/skins/SkinTemplate.php(1252): SkinTemplate->buildPersonalUrls(boolean)
#9 /home/path1/public_html/site1/includes/skins/SkinTemplate.php(782): SkinTemplate->buildContentNavigationUrlsInternal()
#10 /home/path1/public_html/site1/includes/skins/SkinTemplate.php(202): SkinTemplate->getPortletsTemplateData()
#11 /home/path1/public_html/site1/includes/skins/SkinMustache.php(81): SkinTemplate->getTemplateData()
#12 /home/path1/public_html/site1/skins/Vector/includes/SkinVector.php(564): SkinMustache->getTemplateData()
#13 /home/path1/public_html/site1/includes/skins/SkinMustache.php(58): Vector\SkinVector->getTemplateData()
#14 /home/path1/public_html/site1/skins/Vector/includes/SkinVector.php(455): SkinMustache->generateHTML()
#15 /home/path1/public_html/site1/includes/skins/SkinTemplate.php(150): Vector\SkinVector->generateHTML()
#16 /home/path1/public_html/site1/includes/OutputPage.php(2807): SkinTemplate->outputPage()
#17 /home/path1/public_html/site1/includes/MediaWiki.php(926): OutputPage->output(boolean)
#18 /home/path1/public_html/site1/includes/MediaWiki.php(939): MediaWiki::{closure}()
#19 /home/path1/public_html/site1/includes/MediaWiki.php(563): MediaWiki->main()
#20 /home/path1/public_html/site1/index.php(53): MediaWiki->run()
#21 /home/path1/public_html/site1/index.php(46): wfIndexMain()
#22 {main}

Steps to reproduce

  1. Try to open any wiki page after the extension installed

Environment (complete as necessary)

  • PHP Version: 7.4.25
@strange-creature
Copy link
Author

strange-creature commented Aug 1, 2022

Part of the problem was fixed by changing constructor of ForumAuthManager to

	public function __construct( $params = [] ) {
		$loadBalancer = \MediaWiki\MediaWikiServices::getInstance()->getDBLoadBalancer();

		parent::__construct( $loadBalancer, $params );
	}

Now there are no more fatal errors but auth does not work.

@strange-creature
Copy link
Author

The set of errors I've got after the fix for ForumAuthManager:

[error] [YudeZR7klsZtlQCu63XC_wAAABY] /index.php?title=Special:UserLogin&returnto=Main+Page   PHP Notice: Undefined index: boardurl
#0 /home/path1/public_html/site1/extensions/ForumSsoProvider/ForumProvider/smf2.1.php(43): MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /home/path1/public_html/site1/extensions/ForumSsoProvider/ForumSsoProvider.php(161): ForumSoftwareProvidersmf21->getRedirectURL(string, string, boolean)
#2 /home/path1/public_html/site1/extensions/ForumSsoProvider/ForumSsoProvider.php(140): ForumSsoProvider->doRedirect(string, boolean)
#3 /home/path1/public_html/site1/includes/HookContainer/HookContainer.php(338): ForumSsoProvider::onSpecialPageBeforeExecute(SpecialUserLogin, NULL)
#4 /home/path1/public_html/site1/includes/HookContainer/HookContainer.php(137): MediaWiki\HookContainer\HookContainer->callLegacyHook(string, array, array, array)
#5 /home/path1/public_html/site1/includes/HookContainer/HookRunner.php(3638): MediaWiki\HookContainer\HookContainer->run(string, array)
#6 /home/path1/public_html/site1/includes/specialpage/SpecialPage.php(664): MediaWiki\HookContainer\HookRunner->onSpecialPageBeforeExecute(SpecialUserLogin, NULL)
#7 /home/path1/public_html/site1/includes/specialpage/SpecialPageFactory.php(1378): SpecialPage->run(NULL)
#8 /home/path1/public_html/site1/includes/MediaWiki.php(315): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, RequestContext)
#9 /home/path1/public_html/site1/includes/MediaWiki.php(912): MediaWiki->performRequest()
#10 /home/path1/public_html/site1/includes/MediaWiki.php(563): MediaWiki->main()
#11 /home/path1/public_html/site1/index.php(53): MediaWiki->run()
#12 /home/path1/public_html/site1/index.php(46): wfIndexMain()
#13 {main}
[error] [YudeZR7klsZtlQCu63XC_wAAABY] /index.php?title=Special:UserLogin&returnto=Main+Page   PHP Notice: Undefined index: auth_secret
#0 /home/path1/public_html/site1/extensions/ForumSsoProvider/ForumProvider/smf2.1.php(45): MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /home/path1/public_html/site1/extensions/ForumSsoProvider/ForumSsoProvider.php(161): ForumSoftwareProvidersmf21->getRedirectURL(string, string, boolean)
#2 /home/path1/public_html/site1/extensions/ForumSsoProvider/ForumSsoProvider.php(140): ForumSsoProvider->doRedirect(string, boolean)
#3 /home/path1/public_html/site1/includes/HookContainer/HookContainer.php(338): ForumSsoProvider::onSpecialPageBeforeExecute(SpecialUserLogin, NULL)
#4 /home/path1/public_html/site1/includes/HookContainer/HookContainer.php(137): MediaWiki\HookContainer\HookContainer->callLegacyHook(string, array, array, array)
#5 /home/path1/public_html/site1/includes/HookContainer/HookRunner.php(3638): MediaWiki\HookContainer\HookContainer->run(string, array)
#6 /home/path1/public_html/site1/includes/specialpage/SpecialPage.php(664): MediaWiki\HookContainer\HookRunner->onSpecialPageBeforeExecute(SpecialUserLogin, NULL)
#7 /home/path1/public_html/site1/includes/specialpage/SpecialPageFactory.php(1378): SpecialPage->run(NULL)
#8 /home/path1/public_html/site1/includes/MediaWiki.php(315): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, RequestContext)
#9 /home/path1/public_html/site1/includes/MediaWiki.php(912): MediaWiki->performRequest()
#10 /home/path1/public_html/site1/includes/MediaWiki.php(563): MediaWiki->main()
#11 /home/path1/public_html/site1/index.php(53): MediaWiki->run()
#12 /home/path1/public_html/site1/index.php(46): wfIndexMain()
#13 {main}

@jdarwood007
Copy link
Member

I haven't tested at all with 1.38. The later error looks like it isn't including the SMF Settings.php file properly or a global issue. Is your path to the SMF settings.php correct?

@strange-creature
Copy link
Author

I think I've got it.
Doc says that path to forum have to be put into $wgFSPath but the script actually looks into $wgFSPPath.

@jdarwood007
Copy link
Member

Ok, just a typo in the documentation. I will get it updated when I can. I will have to branch the repo because I suspect the changes for 1.38 are not compatible with the current LTS, which is what this is targeting.

@strange-creature
Copy link
Author

Ok. I've got it.

After the fix for $wgFSPPath I've started to get new exception:

[exception] [YunnygFuDDxUnc8-Nd_bbAAAAAQ] /index.php?title=Main_Page   Error: Call to undefined method User::isLoggedIn()
#0 /home/path1/public_html/site1/includes/session/SessionManager.php(525): ForumSsoProvider->provideSessionInfo(WebRequest)
#1 /home/path1/public_html/site1/includes/session/SessionManager.php(247): MediaWiki\Session\SessionManager->getSessionInfoForRequest(WebRequest)
#2 /home/path1/public_html/site1/includes/WebRequest.php(837): MediaWiki\Session\SessionManager->getSessionForRequest(WebRequest)
#3 /home/path1/public_html/site1/includes/session/SessionManager.php(168): WebRequest->getSession()
#4 /home/path1/public_html/site1/includes/Setup.php(878): MediaWiki\Session\SessionManager::getGlobalSession()
#5 /home/path1/public_html/site1/includes/WebStart.php(93): require_once(string)
#6 /home/path1/public_html/site1/index.php(44): require(string)
#7 {main}
[session] User::loadFromSession called before the end of Setup.php
#0 /home/path1/public_html/site1/includes/user/User.php(1891): User->load()
#1 /home/path1/public_html/site1/includes/user/User.php(2529): User->getId()
#2 /home/path1/public_html/site1/includes/user/UserOptionsManager.php(644): User->isRegistered()
#3 /home/path1/public_html/site1/includes/user/UserOptionsManager.php(496): MediaWiki\User\UserOptionsManager->getCacheKey(User)
#4 /home/path1/public_html/site1/includes/user/UserOptionsManager.php(147): MediaWiki\User\UserOptionsManager->loadUserOptions(User, integer)
#5 /home/path1/public_html/site1/includes/user/User.php(2355): MediaWiki\User\UserOptionsManager->getOption(User, string, NULL, boolean)
#6 /home/path1/public_html/site1/includes/context/RequestContext.php(450): User->getOption(string)
#7 /home/path1/public_html/site1/includes/language/Message.php(384): RequestContext->getLanguage()
#8 /home/path1/public_html/site1/includes/language/Message.php(1491): Message->getLanguage()
#9 /home/path1/public_html/site1/includes/language/Message.php(968): Message->fetchMessage()
#10 /home/path1/public_html/site1/includes/language/Message.php(1071): Message->format(string)
#11 /home/path1/public_html/site1/includes/exception/MWExceptionRenderer.php(228): Message->text()
#12 /home/path1/public_html/site1/includes/exception/MWExceptionRenderer.php(160): MWExceptionRenderer::msg(string, string)
#13 /home/path1/public_html/site1/includes/exception/MWExceptionRenderer.php(76): MWExceptionRenderer::reportHTML(Error)
#14 /home/path1/public_html/site1/includes/exception/MWExceptionHandler.php(107): MWExceptionRenderer::output(Error, integer)
#15 /home/path1/public_html/site1/includes/exception/MWExceptionHandler.php(202): MWExceptionHandler::report(Error)
#16 /home/path1/public_html/site1/includes/exception/MWExceptionHandler.php(170): MWExceptionHandler::handleException(Error, string)
#17 [internal function]: MWExceptionHandler::handleUncaughtException(Error)
#18 {main}
[ForumSessionProvider] Database loaded, attempting to load forum member.
[ForumSessionProvider] Querying Forum Provider for member data
[ForumSessionProvider] Forum member found, verifying cookie of 1
[ForumSessionProvider] Member found and verified, verifying access.
[ForumSessionProvider] Cleanup name "MyUsername" using method smf
[ForumSessionProvider] Cleanuped name "MyUsername"
[ForumSessionProvider] Attempting to locate a valid user in MediaWiki or create one if it does not exist

Any clue on what is the cause?

@strange-creature
Copy link
Author

strange-creature commented Aug 3, 2022

It seems that User::isLoggedIn() method was removed in Mediawiki 1.37:

* User->isLoggedIn(), deprecated since 1.36, now emits deprecation warnings. Use
  the method it wraps, User->isRegistered(), instead.

The last content for isLoggedIn was this:

	public function isLoggedIn() {
		return $this->isRegistered();
	}

So isLoggedIn just have to be replaced by isRegistered

@strange-creature
Copy link
Author

Next missing method is User::getUserEffectiveGroups()

	/**
	 * Get the list of implicit group memberships this user has.
	 * This includes all explicit groups, plus 'user' if logged in,
	 * '*' for all accounts, and autopromoted groups
	 *
	 * @deprecated since 1.35 Use UserGroupManager::getUserEffectiveGroups instead
	 *
	 * @param bool $recache Whether to avoid the cache
	 * @return string[] internal group names
	 */
	public function getEffectiveGroups( $recache = false ) {
		return MediaWikiServices::getInstance()
			->getUserGroupManager()
			->getUserEffectiveGroups( $this, $this->queryFlagsUsed, $recache );
	}

@strange-creature
Copy link
Author

Missing method User::setOption():

	/**
	 * Set the given option for a user.
	 *
	 * You need to call saveSettings() to actually write to the database.
	 *
	 * @param string $oname The option to set
	 * @param mixed $val New value to set
	 * @deprecated since 1.35 Use UserOptionsManager::setOption instead
	 */
	public function setOption( $oname, $val ) {
		MediaWikiServices::getInstance()
			->getUserOptionsManager()
			->setOption( $this, $oname, $val );
	}

@strange-creature
Copy link
Author

strange-creature commented Aug 8, 2022

I'm not sure if that's directly useful but there is modified versions of extension files. With them things run fine on MediaWiki 1.38.2. It's likely that you may want to re-format changes to provide better match for your code style.

ForumSsoProvider_patch_for_1.38.zip

I assume these changes are needed for any from 1.35 and newer

@jdarwood007
Copy link
Member

The recent PR #21 should resolve these up. It works on 1.38, but I'm targeting it at 1.39 as I've only been targeting LTS releases.

@live627
Copy link

live627 commented Aug 11, 2022 via email

@jdarwood007
Copy link
Member

I put 1.38+ in the readme. I will bump it to say 1.39 when they release it. Assuming that 1.39 will have no significant changes, it should work.

@live627
Copy link

live627 commented Aug 11, 2022 via email

@jdarwood007
Copy link
Member

WIll do. I don't mind master following the non LTS, but I think it makes sense to branch out for any LTS. If somebody has time to follow the non LTS versions and update the extension, then great.

@berianwilliams
Copy link
Contributor

berianwilliams commented Jan 12, 2023

@jdarwood007 I've tried #21 with MediaWiki 1.39.1 (LTS) and SMF 2.1.3 and it gives me the following errors:

MediaWiki internal error.

Original exception: [b2d045ac594ebc0db0634074] /wiki/Main_Page TypeError: MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider::__construct(): Argument #2 ($userOptionsLookup) must be of type MediaWiki\User\UserOptionsLookup, array given, called in /var/www/MY_FOLDER/public_html/w/extensions/ForumSsoProvider/ForumAuthManager.php on line 35
Backtrace:
from /var/www/MY_FOLDER/public_html/w/includes/auth/TemporaryPasswordPrimaryAuthenticationProvider.php(73)
#0 /var/www/MY_FOLDER/public_html/w/extensions/ForumSsoProvider/ForumAuthManager.php(35): MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider->__construct()
#1 /var/www/MY_FOLDER/public_html/w/vendor/wikimedia/object-factory/src/ObjectFactory.php(247): ForumAuthManager->__construct()
#2 /var/www/MY_FOLDER/public_html/w/vendor/wikimedia/object-factory/src/ObjectFactory.php(152): Wikimedia\ObjectFactory\ObjectFactory::getObjectFromSpec()
#3 /var/www/MY_FOLDER/public_html/w/includes/auth/AuthManager.php(2487): Wikimedia\ObjectFactory\ObjectFactory->createObject()
#4 /var/www/MY_FOLDER/public_html/w/includes/auth/AuthManager.php(2533): MediaWiki\Auth\AuthManager->providerArrayFromSpecs()
#5 /var/www/MY_FOLDER/public_html/w/includes/auth/AuthManager.php(1026): MediaWiki\Auth\AuthManager->getPrimaryAuthenticationProviders()
#6 /var/www/MY_FOLDER/public_html/w/includes/skins/SkinTemplate.php(631): MediaWiki\Auth\AuthManager->canCreateAccounts()
#7 /var/www/MY_FOLDER/public_html/w/includes/skins/SkinTemplate.php(561): SkinTemplate->useCombinedLoginLink()
#8 /var/www/MY_FOLDER/public_html/w/includes/skins/SkinTemplate.php(1262): SkinTemplate->buildPersonalUrls()
#9 /var/www/MY_FOLDER/public_html/w/includes/skins/SkinTemplate.php(790): SkinTemplate->buildContentNavigationUrlsInternal()
#10 /var/www/MY_FOLDER/public_html/w/includes/skins/SkinTemplate.php(229): SkinTemplate->getPortletsTemplateData()
#11 /var/www/MY_FOLDER/public_html/w/includes/skins/SkinMustache.php(88): SkinTemplate->getTemplateData()
#12 /var/www/MY_FOLDER/public_html/w/skins/Vector/includes/SkinVector.php(450): SkinMustache->getTemplateData()
#13 /var/www/MY_FOLDER/public_html/w/includes/skins/SkinMustache.php(58): MediaWiki\Skins\Vector\SkinVector->getTemplateData()
#14 /var/www/MY_FOLDER/public_html/w/includes/skins/SkinTemplate.php(177): SkinMustache->generateHTML()
#15 /var/www/MY_FOLDER/public_html/w/includes/OutputPage.php(2874): SkinTemplate->outputPage()
#16 /var/www/MY_FOLDER/public_html/w/includes/MediaWiki.php(922): OutputPage->output()
#17 /var/www/MY_FOLDER/public_html/w/includes/MediaWiki.php(562): MediaWiki->main()
#18 /var/www/MY_FOLDER/public_html/w/index.php(50): MediaWiki->run()
#19 /var/www/MY_FOLDER/public_html/w/index.php(46): wfIndexMain()
#20 {main}

Exception caught inside exception handler: [b2d045ac594ebc0db0634074] /wiki/Main_Page RuntimeException: Duplicate specifications for id MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider (classes MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider and MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider)
Backtrace:
from /var/www/MY_FOLDER/public_html/w/includes/auth/AuthManager.php(2491)
#0 /var/www/MY_FOLDER/public_html/w/includes/auth/AuthManager.php(2533): MediaWiki\Auth\AuthManager->providerArrayFromSpecs()
#1 /var/www/MY_FOLDER/public_html/w/includes/auth/AuthManager.php(1026): MediaWiki\Auth\AuthManager->getPrimaryAuthenticationProviders()
#2 /var/www/MY_FOLDER/public_html/w/includes/skins/SkinTemplate.php(631): MediaWiki\Auth\AuthManager->canCreateAccounts()
#3 /var/www/MY_FOLDER/public_html/w/includes/skins/SkinTemplate.php(561): SkinTemplate->useCombinedLoginLink()
#4 /var/www/MY_FOLDER/public_html/w/includes/skins/SkinTemplate.php(1262): SkinTemplate->buildPersonalUrls()
#5 /var/www/MY_FOLDER/public_html/w/includes/skins/SkinTemplate.php(790): SkinTemplate->buildContentNavigationUrlsInternal()
#6 /var/www/MY_FOLDER/public_html/w/includes/skins/SkinTemplate.php(229): SkinTemplate->getPortletsTemplateData()
#7 /var/www/MY_FOLDER/public_html/w/includes/skins/SkinMustache.php(88): SkinTemplate->getTemplateData()
#8 /var/www/MY_FOLDER/public_html/w/skins/Vector/includes/SkinVector.php(450): SkinMustache->getTemplateData()
#9 /var/www/MY_FOLDER/public_html/w/includes/skins/SkinMustache.php(58): MediaWiki\Skins\Vector\SkinVector->getTemplateData()
#10 /var/www/MY_FOLDER/public_html/w/includes/skins/SkinTemplate.php(177): SkinMustache->generateHTML()
#11 /var/www/MY_FOLDER/public_html/w/includes/OutputPage.php(2874): SkinTemplate->outputPage()
#12 /var/www/MY_FOLDER/public_html/w/includes/exception/MWExceptionRenderer.php(183): OutputPage->output()
#13 /var/www/MY_FOLDER/public_html/w/includes/exception/MWExceptionRenderer.php(102): MWExceptionRenderer::reportHTML()
#14 /var/www/MY_FOLDER/public_html/w/includes/exception/MWExceptionHandler.php(131): MWExceptionRenderer::output()
#15 /var/www/MY_FOLDER/public_html/w/includes/exception/MWExceptionHandler.php(248): MWExceptionHandler::report()
#16 /var/www/MY_FOLDER/public_html/w/includes/MediaWiki.php(584): MWExceptionHandler::handleException()
#17 /var/www/MY_FOLDER/public_html/w/index.php(50): MediaWiki->run()
#18 /var/www/MY_FOLDER/public_html/w/index.php(46): wfIndexMain()
#19 {main}

Any ideas?

@jdarwood007
Copy link
Member

Seems like they did a few more changes. They both sound like it should be simple to fix. Will try when I get time.

@jdarwood007
Copy link
Member

jdarwood007 commented Jan 14, 2023

@berianwilliams
I can't reproduce the second one. But the first one looks like it can be fixed in ForumAuthManager.php
Find:

	public function __construct( /*array*/ $params = [] ) {
		$loadBalancer = \MediaWiki\MediaWikiServices::getInstance()->getDBLoadBalancer();

		parent::__construct( $loadBalancer, $params );
	}

Replace:

	public function __construct( /*array*/ $params = [] ) {
		$loadBalancer = \MediaWiki\MediaWikiServices::getInstance()->getDBLoadBalancer();
		$userOptionsLookup = \MediaWiki\MediaWikiServices::getInstance()->getUserOptionsLookup();

		parent::__construct( $loadBalancer, $userOptionsLookup, $params );
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants