This is to avoid annoying fatal errors when someone annotated their
hook handler to only expect Language objects, but that expectation
is violated due to this code possibly passing StubUserLang to hooks,
some of which may also assign it to $pageLang.
Even with this in place, it is probably a good idea for hook handlers
to refrain from type hinting parameters that are passed by reference
because their types cannot be guaranteed.
Bug: T214358
Change-Id: I88405a8de4b13675eb5a9d11e9ddc87e20a85fb4
&$pageLang: the page content language. Input can be anything (under control of
hook subscribers), but hooks should return Language objects. Language code
strings are deprecated.
-$userLang: the user language (Language or StubUserLang object)
+$userLang: the user language (Language object)
'PageContentSave': Before an article is saved.
$wikiPage: the WikiPage (object) being saved
$pageLang = Language::factory( $lang );
}
+ // Simplify hook handlers by only passing objects of one type, in case nothing
+ // else has unstubbed the StubUserLang object by now.
+ StubObject::unstub( $wgLang );
+
Hooks::run( 'PageContentLanguage', [ $title, &$pageLang, $wgLang ] );
return wfGetLangObj( $pageLang );