From: Jack Phoenix Date: Wed, 11 Jun 2014 20:00:24 +0000 (+0300) Subject: Apparently for certain (API) requests $this->getTitle() doesn't return a valid Title. X-Git-Tag: 1.31.0-rc.0~15386^2 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=6849fde6cb5cd2dbeec66b3aec266391ca363608;p=lhc%2Fweb%2Fwiklou.git Apparently for certain (API) requests $this->getTitle() doesn't return a valid Title. Usually these are API siteinfo requests (api.php?action=query&meta=siteinfo). In that case, this code used to produce a fatal ("Call to a member function getPageLanguage() on a non-object"). Change-Id: Ifb6f99fe554890ff2719220f58d1b6c1a7a95ddc --- diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 6075d8dbc5..8fd78121db 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1889,7 +1889,12 @@ class OutputPage extends ContextSource { * /w/index.php?title=Main_page&variant=zh-cn should never be served. */ function addAcceptLanguage() { - $lang = $this->getTitle()->getPageLanguage(); + $title = $this->getTitle(); + if ( !$title instanceof Title ) { + return; + } + + $lang = $title->getPageLanguage(); if ( !$this->getRequest()->getCheck( 'variant' ) && $lang->hasVariants() ) { $variants = $lang->getVariants(); $aloption = array();