mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-28 09:40:41 +00:00
Don't silently accept invalid class names
Change-Id: I7888cd3356fcf7433a52455e1cf64522b7e17eb5
This commit is contained in:
parent
cac31dd843
commit
a2566e45a9
|
@ -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 );
|
||||
|
|
Loading…
Reference in a new issue