Page MenuHomePhabricator

TypeError: Argument 6 passed to {closure}() must be an instance of MediaWiki
Closed, ResolvedPublicPRODUCTION ERROR

Description

On deployment to testwikis we got a 500 error when checking special:Version. This was visible when navigating to the page on the browser.

[12d0e1fc-6580-4a06-9559-df8cc8b839f3] /wiki/Special:Version TypeError: Argument 6 passed to {closure}() must be an instance of MediaWiki, instance of MediaWiki\Actions\ActionEntryPoint given, called in /srv/mediawiki/php-1.42.0-wmf.13/includes/HookContainer/HookContainer.php on line 161

Backtrace:

from /srv/mediawiki/private/PrivateSettings.php(227)
#0 /srv/mediawiki/php-1.42.0-wmf.13/includes/HookContainer/HookContainer.php(161): {closure}(MediaWiki\Title\Title, NULL, MediaWiki\Output\OutputPage, MediaWiki\User\User, MediaWiki\Request\WebRequest, MediaWiki\Actions\ActionEntryPoint)
#1 /srv/mediawiki/php-1.42.0-wmf.13/includes/HookContainer/HookRunner.php(934): MediaWiki\HookContainer\HookContainer->run(string, array)
#2 /srv/mediawiki/php-1.42.0-wmf.13/includes/actions/ActionEntryPoint.php(384): MediaWiki\HookContainer\HookRunner->onBeforeInitialize(MediaWiki\Title\Title, NULL, MediaWiki\Output\OutputPage, MediaWiki\User\User, MediaWiki\Request\WebRequest, MediaWiki\Actions\ActionEntryPoint)
#3 /srv/mediawiki/php-1.42.0-wmf.13/includes/actions/ActionEntryPoint.php(151): MediaWiki\Actions\ActionEntryPoint->performRequest()
#4 /srv/mediawiki/php-1.42.0-wmf.13/includes/MediaWikiEntryPoint.php(169): MediaWiki\Actions\ActionEntryPoint->execute()
#5 /srv/mediawiki/php-1.42.0-wmf.13/index.php(50): MediaWiki\MediaWikiEntryPoint->run()
#6 /srv/mediawiki/w/index.php(3): require(string)
#7 {main}

Related Objects

Event Timeline

We can probably just drop the type hint for this?

jeena triaged this task as Unbreak Now! priority.Jan 9 2024, 7:25 PM
jeena added a project: MediaWiki-Engineering.
jeena updated the task description. (Show Details)

(Code is from T336027#8950453.)

Yes. This kind of things is the reason that our hook interfaces do not have type hints.

Looking now...

Jdforrester-WMF assigned this task to daniel.

Looks like this has been Resolved?

Looks like this has been Resolved?

Yep. It was fun, editing secret sauce code with vim over ssh :)

(Code is from T336027#8950453.)

Yes. This kind of things is the reason that our hook interfaces do not have type hints.

If this is supposed to be discouraged then maybe Manual:Hooks/BeforeInitialize shouldn’t include the parameter types in the function signature? I assume this is where [committer name redacted] copied them from – the old signature in PrivateSettings exactly matches this old revision of the documentation.

New hooks that only expose narrow interfaces and value objects in the signature can have type hints.

Type hints should be avoided for any of the old monster classes and anything "internal", since we may want to break it up or deprecate it, and supply a shim to the hook handlers.

If we have a list of these “old monster classes” somewhere, it would be great if we could add it e.g. to Manual:Coding conventions/PHP – I’ve seen this explanation a few times on Phabricator now, but I still wouldn’t know a great place to refer someone else to when they use one of those classes in code review or something. (I’m guessing it’s at least Title, Article, WikiPage, User; evidently MediaWiki; OutputPage and WebRequest too?)

I’ve seen this explanation a few times on Phabricator now, but I still wouldn’t know a great place to refer someone else to when they use one of those classes in code review or something. (I’m guessing it’s at least Title, Article, WikiPage, User; evidently MediaWiki; OutputPage and WebRequest too?)

These are the "everywhere" monsters. But hooks should also not bind to stuff like EditPage, since it may be split up. Or OutputPage, for the same reason. Basically, the larger the class, the more problematic it is for hooks to bind to it.

Krinkle changed the visibility from "Custom Policy" to "Public (No Login Required)".
Krinkle changed the edit policy from "Custom Policy" to "All Users".
Restricted Application changed the subtype of this task from "Security Issue" to "Production Error". · View Herald TranscriptJan 14 2025, 10:31 PM