From: Brian Wolff Date: Mon, 12 Aug 2013 18:29:29 +0000 (-0300) Subject: Make msg method of DerivativeContext work properly. X-Git-Tag: 1.31.0-rc.0~18948 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=45024d218d782576d5b1da62cf6ba3d53de1c736;p=lhc%2Fweb%2Fwiklou.git Make msg method of DerivativeContext work properly. Previously, the msg method was not taking into account any changes to the context, and was just using the original context. For example, if you had a DerivativeContext object, where the original context had a language of en, and then you did $derivContext->setLanguage( 'fr' );, $derivContext->msg( 'foo' ) was still outputting stuff in english instead of french. Change-Id: I4a87e0e2664e77bf79a80c873db384e0c3f607e7 --- diff --git a/includes/context/DerivativeContext.php b/includes/context/DerivativeContext.php index eda56a7d55..d4caf05dab 100644 --- a/includes/context/DerivativeContext.php +++ b/includes/context/DerivativeContext.php @@ -281,4 +281,20 @@ class DerivativeContext extends ContextSource { return $this->getContext()->getSkin(); } } + + /** + * Get a message using the current context. + * + * This can't just inherit from ContextSource, since then + * it would set only the original context, and not take + * into account any changes. + * + * @param String Message name + * @param Variable number of message arguments + * @return Message + */ + public function msg() { + $args = func_get_args(); + return call_user_func_array( 'wfMessage', $args )->setContext( $this ); + } }