From: Gergő Tisza Date: Tue, 7 Jun 2016 20:39:01 +0000 (+0000) Subject: Fix Status::getMessage for the multiple errors, $shortContext only case X-Git-Tag: 1.31.0-rc.0~6692 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=4d294bceab9669ee7169248e92fe747a3b5fce7c;p=lhc%2Fweb%2Fwiklou.git Fix Status::getMessage for the multiple errors, $shortContext only case Remove $msgCount++ which does not seem to have any non-harmful purpose. Also try to explain what the hell the method does. Change-Id: Ibdf40ff13a4a9d294a6bc6f778a14fb2633c2f70 --- diff --git a/includes/Status.php b/includes/Status.php index d01f2693f3..45d8bed2fa 100644 --- a/includes/Status.php +++ b/includes/Status.php @@ -251,12 +251,22 @@ class Status { } /** - * Get the error list as a Message object + * Get a bullet list of the errors as a Message object. * - * @param string|string[] $shortContext A short enclosing context message name (or an array of - * message names), to be used when there is a single error. - * @param string|string[] $longContext A long enclosing context message name (or an array of - * message names), for a list. + * $shortContext and $longContext can be used to wrap the error list in some text. + * $shortContext will be preferred when there is a single error; $longContext will be + * preferred when there are multiple ones. In either case, $1 will be replaced with + * the list of errors. + * + * $shortContext is assumed to use $1 as an inline parameter: if there is a single item, + * it will not be made into a list; if there are multiple items, newlines will be inserted + * around the list. + * $longContext is assumed to use $1 as a standalone parameter; it will always receive a list. + * + * If both parameters are missing, and there is only one error, no bullet will be added. + * + * @param string|string[] $shortContext A message name or an array of message names. + * @param string|string[] $longContext A message name or an array of message names. * @param string|Language $lang Language to use for processing messages * @return Message */ @@ -287,10 +297,6 @@ class Status { $msgs = $this->getErrorMessageArray( $rawErrors, $lang ); $msgCount = count( $msgs ); - if ( $shortContext ) { - $msgCount++; - } - $s = new RawMessage( '* $' . implode( "\n* \$", range( 1, $msgCount ) ) ); $s->params( $msgs )->parse();