https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113223
Revision: 113223
Author: nikerabbit
Date: 2012-03-07 10:13:58 +0000 (Wed, 07 Mar 2012)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/phase3/includes/Message.php
trunk/phase3/includes/SpecialPage.php
Modified: trunk/phase3/includes/Message.php
===================================================================
--- trunk/phase3/includes/Message.php 2012-03-07 10:07:32 UTC (rev 113222)
+++ trunk/phase3/includes/Message.php 2012-03-07 10:13:58 UTC (rev 113223)
@@ -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:
*
@@ -342,6 +341,18 @@
}
/**
+ * 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
* @return Message: $this
Modified: trunk/phase3/includes/SpecialPage.php
===================================================================
--- trunk/phase3/includes/SpecialPage.php 2012-03-07 10:07:32 UTC (rev
113222)
+++ trunk/phase3/includes/SpecialPage.php 2012-03-07 10:13:58 UTC (rev
113223)
@@ -768,7 +768,15 @@
// 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;
}
/**
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs