Use wikiId both server and client side

When creating the various notification sources,
the server was indexing them with wfWikiID() but
the client was using wgDBname to find which one
is local and which are remote. On some wikis,
like TWN, wfWikiID() includes a db suffix so
the JS app on Special:Notifications is failing to
find the local source and errors.

Bug: T167336
Change-Id: Id60f723b615fb7db54a6f17b1c1be20dfe98e36c
This commit is contained in:
Stephane Bisson 2019-04-19 11:04:52 -04:00
parent 77126f0c47
commit f5f59a503b
5 changed files with 9 additions and 7 deletions

View file

@ -955,6 +955,8 @@ class EchoHooks {
'notice' => $seenMsgTime,
] );
$sk->getOutput()->addJsConfigVars( 'wgWikiId', wfWikiID() );
$msgFormattedCount = EchoNotificationController::formatNotificationCount( $msgCount );
$alertFormattedCount = EchoNotificationController::formatNotificationCount( $alertCount );

View file

@ -30,7 +30,7 @@ class ApiEchoUnreadNotificationPages extends ApiQueryBase {
$params = $this->extractRequestParams();
$result = [];
if ( in_array( wfWikiId(), $this->getRequestedWikis() ) ) {
if ( in_array( wfWikiID(), $this->getRequestedWikis() ) ) {
$result[wfWikiID()] = $this->getFromLocal( $params['limit'], $params['grouppages'] );
}

View file

@ -107,11 +107,11 @@
return Array.isArray( sources ) ?
(
sources.indexOf( 'local' ) !== -1 ||
sources.indexOf( mw.config.get( 'wgDBname' ) ) !== -1
sources.indexOf( mw.config.get( 'wgWikiId' ) ) !== -1
) :
(
sources === 'local' ||
sources === mw.config.get( 'wgDBname' )
sources === mw.config.get( 'wgWikiId' )
);
};

View file

@ -91,11 +91,11 @@
foreignSources = {};
for ( source in data ) {
if ( source !== mw.config.get( 'wgDBname' ) ) {
if ( source !== mw.config.get( 'wgWikiId' ) ) {
// Collect sources for API
foreignSources[ source ] = data[ source ].source;
}
result[ source === mw.config.get( 'wgDBname' ) ? 'local' : source ] = data[ source ];
result[ source === mw.config.get( 'wgWikiId' ) ? 'local' : source ] = data[ source ];
}
// Register the foreign sources in the API

View file

@ -103,7 +103,7 @@
myEvt.mobile = mobile || mw.config.get( 'skin' ) === 'minerva';
}
if ( notifWiki && notifWiki !== mw.config.get( 'wgDBname' ) && notifWiki !== 'local' ) {
if ( notifWiki && notifWiki !== mw.config.get( 'wgWikiId' ) && notifWiki !== 'local' ) {
myEvt.notifWiki = notifWiki;
}
@ -123,7 +123,7 @@
var i, len, key;
for ( i = 0, len = notificationIds.length; i < len; i++ ) {
key = notifWiki && notifWiki !== mw.config.get( 'wgDBname' ) && notifWiki !== 'local' ?
key = notifWiki && notifWiki !== mw.config.get( 'wgWikiId' ) && notifWiki !== 'local' ?
notificationIds[ i ] + '-' + notifWiki :
notificationIds[ i ];