Page MenuHomePhabricator

wgWikibaseItemId should be available on the edit page
Open, Needs TriagePublic


E.g. it can be used on the Main Page:

mw.config.get( 'wgWikibaseItemId' )
> "Q5296"

But can't be used on the edit page:

mw.config.get( 'wgWikibaseItemId' )
> null

Event Timeline

putnik created this task.Jan 22 2018, 1:25 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 22 2018, 1:25 AM
valerio.bozzolan added a comment.EditedAug 2 2018, 8:20 PM

Hoping to give additional visibility to this problem, I've documented this variable here:

valerio.bozzolan added a comment.EditedAug 3 2018, 10:50 PM

I've found where this variable is defined:

Wikbase repository / client/ClientHooks.php:

 * Add the connected item prefixed id as a JS config variable, for gadgets etc.
 * @param OutputPage $out
 * @param Skin $skin
public static function onBeforePageDisplayAddJsConfig( OutputPage $out, Skin $skin ) {
    $prefixedId = $out->getProperty( 'wikibase_item' );

    if ( $prefixedId !== null ) {
        $out->addJsConfigVars( 'wgWikibaseItemId', $prefixedId );

That method is attached to the [BeforePageDisplay]( hook, as far I can see:

Wikibase repository / client/WikibaseClient.php:

$wgHooks['BeforePageDisplay'][] = '\Wikibase\ClientHooks::onBeforePageDisplayAddJsConfig';

So I think that the problem is that it should be hooked also to one other hook listed here: Manual:Hooks.

The most notable hook I think it's [AlternateEdit]( which description is:

This hook gets called at the beginning of &action=edit, before any user permissions are checked or any edit checking is performed.

AS added a subscriber: AS.Nov 30 2019, 3:42 AM

Is there any workaround?

He7d3r added a subscriber: He7d3r.Jul 14 2020, 4:50 PM