From 499f643befc72f515f8f4b4bf984772b0f32a2b2 Mon Sep 17 00:00:00 2001 From: Florian Schmidt Date: Mon, 14 Aug 2017 18:31:39 +0200 Subject: [PATCH] Move RawMessage out of Message.php to its own file Change-Id: Idae9617dafa3c314085eb097f78f1c8d38672f31 --- autoload.php | 2 +- includes/Message.php | 53 ------------------------------ includes/RawMessage.php | 72 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 54 deletions(-) create mode 100644 includes/RawMessage.php diff --git a/autoload.php b/autoload.php index 508e75bdc8..d9e85bd39d 100644 --- a/autoload.php +++ b/autoload.php @@ -1180,7 +1180,7 @@ $wgAutoloadLocalClasses = [ 'RangeChronologicalPager' => __DIR__ . '/includes/pager/RangeChronologicalPager.php', 'RangeDifference' => __DIR__ . '/includes/diff/DiffEngine.php', 'RawAction' => __DIR__ . '/includes/actions/RawAction.php', - 'RawMessage' => __DIR__ . '/includes/Message.php', + 'RawMessage' => __DIR__ . '/includes/RawMessage.php', 'ReadOnlyError' => __DIR__ . '/includes/exception/ReadOnlyError.php', 'ReadOnlyMode' => __DIR__ . '/includes/ReadOnlyMode.php', 'ReassignEdits' => __DIR__ . '/maintenance/reassignEdits.php', diff --git a/includes/Message.php b/includes/Message.php index 8777c6fee1..0240fa7477 100644 --- a/includes/Message.php +++ b/includes/Message.php @@ -1344,56 +1344,3 @@ class Message implements MessageSpecifier, Serializable { return $this->extractParam( new RawMessage( $vars, $params ), $format ); } } - -/** - * Variant of the Message class. - * - * Rather than treating the message key as a lookup - * value (which is passed to the MessageCache and - * translated as necessary), a RawMessage key is - * treated as the actual message. - * - * All other functionality (parsing, escaping, etc.) - * is preserved. - * - * @since 1.21 - */ -class RawMessage extends Message { - - /** - * Call the parent constructor, then store the key as - * the message. - * - * @see Message::__construct - * - * @param string $text Message to use. - * @param array $params Parameters for the message. - * - * @throws InvalidArgumentException - */ - public function __construct( $text, $params = [] ) { - if ( !is_string( $text ) ) { - throw new InvalidArgumentException( '$text must be a string' ); - } - - parent::__construct( $text, $params ); - - // The key is the message. - $this->message = $text; - } - - /** - * Fetch the message (in this case, the key). - * - * @return string - */ - public function fetchMessage() { - // Just in case the message is unset somewhere. - if ( $this->message === null ) { - $this->message = $this->key; - } - - return $this->message; - } - -} diff --git a/includes/RawMessage.php b/includes/RawMessage.php new file mode 100644 index 0000000000..9a0d947dfd --- /dev/null +++ b/includes/RawMessage.php @@ -0,0 +1,72 @@ +message = $text; + } + + /** + * Fetch the message (in this case, the key). + * + * @return string + */ + public function fetchMessage() { + // Just in case the message is unset somewhere. + if ( $this->message === null ) { + $this->message = $this->key; + } + + return $this->message; + } + +} -- 2.20.1