Topic on Project:Support desk/Flow

[Developer question] ExtensionRegistry::getInstance()->isLoaded( 'OpenIDConnect' ) always returns false [solved]

2
Wikinaut (talkcontribs)
[updated] filed as bug https://phabricator.wikimedia.org/T356596

Problem: ...->isLoaded( extension ) always returns false, also if that extension is loaded.

Situation:

  • mediawiki 1.41.0

In my extension ShowOIDCIdentity I need to check whether the dependency extension OpenIDConnect is really loaded.

This done in that way previously in LocalSettings:

wfLoadExtension( 'OpenIDConnect' );
...
wfLoadExtension( 'ShowOIDCIdentity' );

myextension/Hooks.php;

Namespace MediaWiki\Extension\ShowOIDCIdentity;
use ExtensionRegistry;

class Hooks {
/**
  * @param User $user
  * @param array $preferences
  */
public static function onGetPreferences( $user, &$preferences ) {

if ( ExtensionRegistry::getInstance()->isLoaded( 'OpenIDConnect' ) )

/*** is always false even if OpenIDConnect is correctly loaded and working ***/

I cannot find a problem here, but it is not working.

Wikinaut (talkcontribs)

Solved. and added as tip to https://www.mediawiki.org/wiki/Manual:Developing_extensions#Handling_dependencies


I need to report:

While loading as

wfLoadExtension( "OpenIDConnect" )

works,

the function

ExtensionRegistry::getInstance()->isLoaded( 'OpenIDConnect' )

function isLoaded appears to check the - different - name in extension.json, which is "OpenID Connect" with a space!

So I had to use

ExtensionRegistry::getInstance()->isLoaded( 'OpenID Connect' )


This should be corrected in some way upstream (mediawiki extension registry workflow) and in the documentation.

Reply to "[Developer question] ExtensionRegistry::getInstance()->isLoaded( 'OpenIDConnect' ) always returns false [solved]"