Log error when array_flip fails in MessageCache load
authorGilles Dubuc <gilles@wikimedia.org>
Mon, 19 Nov 2018 10:49:23 +0000 (11:49 +0100)
committerGilles Dubuc <gilles@wikimedia.org>
Mon, 19 Nov 2018 10:49:23 +0000 (11:49 +0100)
Bug: T208897
Change-Id: If6e7a6a3019abbdc11b6604ec706cc88bfddf128

includes/cache/MessageCache.php

index 5ada42f..b669fcd 100644 (file)
@@ -270,6 +270,17 @@ class MessageCache {
 
                $this->overridable = array_flip( Language::getMessageKeysFor( $code ) );
 
+               // T208897 array_flip can fail and return null
+               if ( is_null( $this->overridable ) ) {
+                       LoggerFactory::getInstance( 'MessageCache' )->error(
+                               __METHOD__ . ': $this->overridable is null',
+                               [
+                                       'message_keys' => Language::getMessageKeysFor( $code ),
+                                       'code' => $code
+                               ]
+                       );
+               }
+
                # 8 lines of code just to say (once) that message cache is disabled
                if ( $this->mDisable ) {
                        static $shownDisabled = false;