Page MenuHomePhabricator

opensearch_desc calls Title::getLocalURL which unstubs wgUser on wikis with a variant
Closed, ResolvedPublic

Description

zh.wiktionary.org/w/opensearch_desc.php
/srv/mediawiki/php-1.28.0-wmf.1/includes/session/SessionManager.php:985 BadMethodCallException
Sessions are supposed to be disabled for this entry point
/srv/mediawiki/php-1.28.0-wmf.1/includes/session/SessionManager.php:301
/srv/mediawiki/php-1.28.0-wmf.1/includes/session/SessionManager.php:235
/srv/mediawiki/php-1.28.0-wmf.1/includes/session/SessionManager.php:185
/srv/mediawiki/php-1.28.0-wmf.1/includes/WebRequest.php:700
/srv/mediawiki/php-1.28.0-wmf.1/includes/user/User.php:1211
/srv/mediawiki/php-1.28.0-wmf.1/includes/user/User.php:405
/srv/mediawiki/php-1.28.0-wmf.1/includes/user/User.php:5171
/srv/mediawiki/php-1.28.0-wmf.1/includes/user/User.php:2793
/srv/mediawiki/php-1.28.0-wmf.1/includes/context/RequestContext.php:363
/srv/mediawiki/php-1.28.0-wmf.1/includes/StubObject.php:197
/srv/mediawiki/php-1.28.0-wmf.1/includes/StubObject.php:159
/srv/mediawiki/php-1.28.0-wmf.1/includes/StubObject.php:104
/srv/mediawiki/php-1.28.0-wmf.1/includes/StubObject.php:129
/srv/mediawiki/php-1.28.0-wmf.1/includes/Title.php:1752
/srv/mediawiki/php-1.28.0-wmf.1/includes/Title.php:1846
/srv/mediawiki/php-1.28.0-wmf.1/opensearch_desc.php:85
/srv/mediawiki/w/opensearch_desc.php:3

opensearch_desc.php needs to return a "template" URL for Special:Search on which browsers can do a string replacement to get the actual search URL. That includes calling Title::getLocalURL which might need to replace variant parameters in the URL for variant wikis, and for that it needs to check whether the page language matches the site language. For that it needs to access $wgContLang, and that seems to be an instance of StubUserLang. Not sure how that can happen.

Details

Related Gerrit Patches:

Event Timeline

Tgr created this task.May 16 2016, 2:30 PM
Restricted Application added subscribers: Zppix, Aklapper. · View Herald TranscriptMay 16 2016, 2:30 PM
Anomie added a subscriber: Anomie.May 16 2016, 4:56 PM

The line in question is Title.php line 1752

&& $wgContLang->getCode() === $this->getPageLanguage()->getCode()

It's not $wgContLang in that line that's the problem, it's $this->getPageLanguage():

public function getPageLanguage() {
    global $wgLang, $wgLanguageCode;
    if ( $this->isSpecialPage() ) {
        // special pages are in the user language
        return $wgLang;
    }

Change 288985 had a related patch set uploaded (by Anomie):
Avoid unstubbing $wgLang in Title::getLocalURL

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

Change 288985 merged by jenkins-bot:
Avoid unstubbing $wgLang in Title::getLocalURL

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

Tgr closed this task as Resolved.Nov 22 2016, 10:25 PM
Tgr assigned this task to Anomie.
Tgr removed a project: Patch-For-Review.

Was fixed a while ago.