From: Niklas Laxström Date: Wed, 7 Mar 2012 10:13:58 +0000 (+0000) Subject: My proposed fix to bug 34987: gender not working in many special pages. X-Git-Tag: 1.31.0-rc.0~24349 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles_versions%22%2C%22id_article=%24id_article%22%29%20.%20%22?a=commitdiff_plain;h=455d6dae19a5df900d8808283ce4e768cf307f59;p=lhc%2Fweb%2Fwiklou.git My proposed fix to bug 34987: gender not working in many special pages. I haven't checked if there are other places whereh context is set to Message class, but if there are they might need a fix too. --- diff --git a/includes/Message.php b/includes/Message.php index 3c5d5d7d65..73914d7b92 100644 --- a/includes/Message.php +++ b/includes/Message.php @@ -90,8 +90,7 @@ * ->plain(); * @endcode * - * @note You cannot parse the text except in the content or interface - * @note languages + * @note You can parse the text only in the content or interface languages * * @section message_compare_old Comparison with old wfMsg* functions: * @@ -341,6 +340,18 @@ class Message { return $this; } + /** + * Allows manipulating the interface message flag directly. + * Can be used to restore the flag after setting a language. + * @param $value bool + * @return Message: $this + * @since 1.20 + */ + public function setInterfaceMessageFlag( $value ) { + $this->interface = (bool) $value; + return $this; + } + /** * Enable or disable database use. * @param $value Boolean diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index c9c6f025bb..3f8b88e1d3 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -768,7 +768,15 @@ class SpecialPage { // Works fine as the first parameter, which appears elsewhere in the // code base. Sighhhh. $args = func_get_args(); - return call_user_func_array( array( $this->getContext(), 'msg' ), $args ); + $message = call_user_func_array( array( $this->getContext(), 'msg' ), $args ); + // RequestContext passes context to wfMessage, and the language is set from + // the context, but setting the language for Message class removes the + // interface message status, which breaks for example usernameless gender + // invokations. Restore the flag when not including special page in content. + if ( !$this->including() ) { + $message->setInterfaceMessageFlag( true ); + } + return $message; } /**