From a2566e45a9537279cc306a1cab7d4a57228349c7 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Mon, 15 Jun 2015 19:21:01 -0700 Subject: [PATCH] Don't silently accept invalid class names Change-Id: I7888cd3356fcf7433a52455e1cf64522b7e17eb5 --- includes/formatters/NotificationFormatter.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/formatters/NotificationFormatter.php b/includes/formatters/NotificationFormatter.php index 2604ea363..e78e5672b 100644 --- a/includes/formatters/NotificationFormatter.php +++ b/includes/formatters/NotificationFormatter.php @@ -95,20 +95,20 @@ abstract class EchoNotificationFormatter { /** * Create an EchoNotificationFormatter from the supplied parameters. * @param $parameters array Associative array. - * Select the class of formatter to use with the 'class' field. + * Select the class of formatter to use with the 'formatter-class' field. * For other parameters, see the appropriate class' constructor. - * @throws MWException + * @throws RuntimeException * @return EchoNotificationFormatter object. */ public static function factory( $parameters ) { - $class = null; if ( isset( $parameters['formatter-class'] ) ) { $class = $parameters['formatter-class']; + } else { + $class = 'EchoBasicFormatter'; } - // Default to basic formatter - if ( !$class || !class_exists( $class ) ) { - $class = 'EchoBasicFormatter'; + if ( !class_exists( $class ) ) { + throw new RuntimeException( "Class $class does not exist" ); } return new $class( $parameters );