Follow-up 9c9cfa2ec3d7: fix non-session entry point error
authorRoan Kattouw <roan.kattouw@gmail.com>
Thu, 4 Jul 2019 00:28:07 +0000 (17:28 -0700)
committerRoan Kattouw <roan.kattouw@gmail.com>
Thu, 4 Jul 2019 00:28:07 +0000 (17:28 -0700)
Even though we shouldn't really need to, we have to set the language on
the RawMessage we generate when the tag message doesn't exist. Because
both MessageLocalizer and RawMessage are kind of hacky and not fully
supported, I had to hack around the various gaps in our infrastructure.
See my comment on the task for details.

Bug: T227233
Change-Id: I5ab3e9b1e8d34b1af531dba33b2f92fcd7f12192

includes/changetags/ChangeTags.php

index 14b53d3..40f7180 100644 (file)
@@ -149,7 +149,13 @@ class ChangeTags {
                $msg = $context->msg( "tag-$tag" );
                if ( !$msg->exists() ) {
                        // No such message
-                       return new RawMessage( '$1', [ Message::plaintextParam( $tag ) ] );
+                       return ( new RawMessage( '$1', [ Message::plaintextParam( $tag ) ] ) )
+                               // HACK MessageLocalizer doesn't have a way to set the right language on a RawMessage,
+                               // so extract the language from $msg and use that.
+                               // The language doesn't really matter, but we need to set it to avoid requesting
+                               // the user's language from session-less entry points (T227233)
+                               ->inLanguage( $msg->getLanguage() );
+
                }
                if ( $msg->isDisabled() ) {
                        // The message exists but is disabled, hide the tag.