Reverted r113177 per CR
[lhc/web/wiklou.git] / includes / Message.php
index d9ee14f..7357ed7 100644 (file)
@@ -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:
  *
@@ -295,6 +294,7 @@ class Message {
        public function setContext( IContextSource $context ) {
                $this->inLanguage( $context->getLanguage() );
                $this->title( $context->getTitle() );
+               $this->interface = true;
 
                return $this;
        }
@@ -341,6 +341,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
@@ -570,7 +582,10 @@ class Message {
        protected function fetchMessage() {
                if ( !isset( $this->message ) ) {
                        $cache = MessageCache::singleton();
-                       if ( is_array($this->key) ) {
+                       if ( is_array( $this->key ) ) {
+                               if ( !count( $this->key ) ) {
+                                       throw new MWException( "Given empty message key array." );
+                               }
                                foreach ( $this->key as $key ) {
                                        $message = $cache->get( $key, $this->useDatabase, $this->language );
                                        if ( $message !== false && $message !== '' ) {