OOUIHTMLForm: Make sure arguments to OOUI\HtmlSnippet are really strings
authorBartosz Dziewoński <matma.rex@gmail.com>
Thu, 16 Jul 2015 18:59:11 +0000 (20:59 +0200)
committerLegoktm <legoktm.wikipedia@gmail.com>
Thu, 16 Jul 2015 19:08:50 +0000 (19:08 +0000)
    Catchable fatal error: Method OOUI\HtmlSnippet::__toString()
    must return a string value in
    /var/www/html/w/vendor/oojs/oojs-ui/php/Element.php on line 245

$this->getHelpText() can return null.

Maybe OOUI\HtmlSnippet should be doing the casting instead, but it
currently doesn't.

Follow-up to 3ec3f08ca5c7bfae820bbc8085eff0809abd688b.

Change-Id: I0bb2a1594ea5ffd86bf8abd41c13f9451df256d5

includes/htmlform/HTMLFormField.php

index 3e30d79..70615d9 100644 (file)
@@ -581,11 +581,12 @@ abstract class HTMLFormField {
                }
 
                $fieldType = get_class( $this );
+               $helpText = $this->getHelpText();
                $field = new OOUI\FieldLayout( $inputField, array(
                        'classes' => array( "mw-htmlform-field-$fieldType", $this->mClass, $errorClass ),
                        'align' => $this->getLabelAlignOOUI(),
                        'label' => $this->getLabel(),
-                       'help' => new OOUI\HtmlSnippet( $this->getHelpText() ),
+                       'help' => $helpText !== null ? new OOUI\HtmlSnippet( $helpText ) : null,
                        'infusable' => $infusable,
                ) );