Page MenuHomePhabricator

HookContainer change: Error: Class 'PSExtensionHandler' not found
Closed, ResolvedPublic

Description

Splitting from T338213: CI + Beta errors: Call to undefined method MediaWiki\Extension\CentralAuth\Hooks\Handlers\AbuseFilterHookHandler::onAbuseFilter-generateUserVars() for visibility:

On translatewiki.net we had the following error pop up when running the rebuildLocalisationCache script:

[891c19fc2a4c905abf364b8d] [no req]   Error: Class 'PSExtensionHandler' not found
Backtrace:
from /srv/mediawiki/workdir/extensions/PageForms/includes/PF_PageSchemas.php(15)
#0 /srv/mediawiki/workdir/includes/AutoLoader.php(222): require()
#1 [internal function]: AutoLoader::autoload()
#2 [internal function]: spl_autoload_call()
#3 /srv/mediawiki/workdir/includes/HookContainer/HookContainer.php(344): is_callable()
#4 /srv/mediawiki/workdir/includes/HookContainer/HookContainer.php(521): MediaWiki\HookContainer\HookContainer->normalizeHandler()
#5 /srv/mediawiki/workdir/includes/HookContainer/HookContainer.php(450): MediaWiki\HookContainer\HookContainer->getHandlers()
#6 /srv/mediawiki/workdir/extensions/SemanticMediaWiki/src/MediaWiki/Hooks.php(152): MediaWiki\HookContainer\HookContainer->register()
#7 /srv/mediawiki/workdir/extensions/SemanticMediaWiki/src/Setup.php(389): SMW\MediaWiki\Hooks->register()
#8 /srv/mediawiki/workdir/extensions/SemanticMediaWiki/src/Setup.php(152): SMW\Setup->registerHooks()
#9 /srv/mediawiki/workdir/extensions/SemanticMediaWiki/includes/SemanticMediaWiki.php(84): SMW\Setup->init()
#10 /srv/mediawiki/workdir/includes/Setup.php(564): SemanticMediaWiki::onExtensionFunction()
#11 /srv/mediawiki/workdir/maintenance/run.php(49): require_once(string)
#12 {main}

Reverting this change fixed the issue:

[mediawiki/core@master] Simplify HookContainer (v2)
https://gerrit.wikimedia.org/r/927596

It seems some change is now causing auto-loading of a hooks class to trigger, which then causes a fatal because it is extending a class that isn't available

Event Timeline

abi_ updated the task description. (Show Details)

Does anyone have any idea how to fix this?

This is my fault, see https://gerrit.wikimedia.org/r/c/mediawiki/core/+/927596

The point at which hook handlers get normalized so they can be invoked changed, and the normalization code was streamlined to make it more predictable and reliable.

As a side-effect, it is no longer possible to register "broken" hook handlers - i.e. hook handlers that need a class that doesn't exist. I guess previously, this would not have failed as long as the hook was never actually called. But if the hook was called, this would already have exploded in the past, right?

I can think of a couple of ways to make this fail in fewer cases, and in less spectacular ways. But it would still fail...

Change 931079 had a related patch set uploaded (by Yaron Koren; author: Yaron Koren):

[mediawiki/extensions/PageForms@master] Avoid including PFPageSchemas class directly in extension.json

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

@daniel - thanks for the explanation. Looking at the code again, it does seem like there's a pretty easy way to fix the problem, on the Page Forms side. I just created a patch that I think takes care of it.

Change 931079 merged by jenkins-bot:

[mediawiki/extensions/PageForms@master] Avoid including PFPageSchemas class directly in extension.json

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

Change 931312 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] HookContainer: allow registering broken callables.

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

I came up with a hack that allows "broken callables" to be registered. I don't love it, but it's kind of neat in its own twisted way...

Oh well; doesn't matter. I think moving that function to the PFHooks class was probably the right decision no matter what.

Yaron_Koren claimed this task.

I assume this can be closed.

@daniel I see the patch was not merged, do you plan to continue working on this?

Oh! I didn't even notice that 2nd patch. I thought that "I came up with a hack ..." message was just a random statement.

And looking at that patch now, it's probably best to remove this bug from its commit message, since this specific bug is already fixed.

That said, anyone can feel free to re-open this.

Change 939764 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] HookContainer: avoid instantiation of handlers when calling register()

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

When manually patching my server with @daniel s patch. I can run the updater script. However, when trying to access a feature of that specific extension, the bug is still there cf.

https://wiki.physikerwelt.de/wiki/Spezial:Daten_durchsuchen/Theoretische_Physik

However, normal pages load

https://wiki.physikerwelt.de/wiki/Zust%C3%A4nde_mit_Bahn-_und_Spinvariablen

with warnings.

When manually patching my server with @daniel s patch. I can run the updater script. However, when trying to access a feature of that specific extension, the bug is still there cf.

https://wiki.physikerwelt.de/wiki/Spezial:Daten_durchsuchen/Theoretische_Physik

It is a duplicate of https://phabricator.wikimedia.org/T289544

So the fix works for me without any problems.

Change 939764 merged by jenkins-bot:

[mediawiki/core@master] HookContainer: avoid instantiation of handlers when calling register()

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

Change 940918 had a related patch set uploaded (by Zabe; author: Daniel Kinzler):

[mediawiki/core@wmf/1.41.0-wmf.18] HookContainer: avoid instantiation of handlers when calling register()

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

Change 940918 merged by jenkins-bot:

[mediawiki/core@wmf/1.41.0-wmf.18] HookContainer: avoid instantiation of handlers when calling register()

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

Mentioned in SAL (#wikimedia-operations) [2023-07-24T22:36:21Z] <zabe@deploy1002> Started scap: Backport for [[gerrit:940919|client: Avoid dynamically registering hook handlers (T341102)]], [[gerrit:940918|HookContainer: avoid instantiation of handlers when calling register() (T341102 T340113 T339834)]]

Mentioned in SAL (#wikimedia-operations) [2023-07-24T22:37:46Z] <zabe@deploy1002> zabe: Backport for [[gerrit:940919|client: Avoid dynamically registering hook handlers (T341102)]], [[gerrit:940918|HookContainer: avoid instantiation of handlers when calling register() (T341102 T340113 T339834)]] synced to the testservers mwdebug2002.codfw.wmnet, mwdebug2001.codfw.wmnet, mwdebug1001.eqiad.wmnet, mwdebug1002.eqiad.wmnet, and mw-debug kubernetes deployment (accessible via k8s-experime

Mentioned in SAL (#wikimedia-operations) [2023-07-24T22:46:20Z] <zabe@deploy1002> Finished scap: Backport for [[gerrit:940919|client: Avoid dynamically registering hook handlers (T341102)]], [[gerrit:940918|HookContainer: avoid instantiation of handlers when calling register() (T341102 T340113 T339834)]] (duration: 09m 59s)

Change 931312 merged by jenkins-bot:

[mediawiki/core@master] HookContainer: allow registering broken callables.

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