r91267 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91266‎ | r91267 | r91268 >
Date:14:44, 1 July 2011
Author:yaron
Status:deferred (Comments)
Tags:
Comment:
Added fix to counteract possible bug in Xml::element(), for 'textarea' tag - plus fix to counteract possible bug in newer versions of CategoryTree extension
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormInputs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.php
@@ -351,6 +351,11 @@
352352 $textarea_attrs['onKeyDown'] = $maxLengthJSCheck;
353353 $textarea_attrs['onKeyUp'] = $maxLengthJSCheck;
354354 }
 355+ // Bug in Xml::element()? It doesn't close the textarea tag
 356+ // properly if the text inside is null - set it to '' instead.
 357+ if ( is_null( $cur_value ) ) {
 358+ $cur_value = '';
 359+ }
355360 $text = Xml::element( 'textarea', $textarea_attrs, $cur_value, false );
356361 $spanClass = "inputSpan";
357362 if ( $is_mandatory ) { $spanClass .= " mandatoryFieldSpan"; }
@@ -1492,7 +1497,14 @@
14931498
14941499 global $wgCategoryTreeMaxDepth;
14951500 $wgCategoryTreeMaxDepth = 10;
1496 - $tree = efCategoryTreeParserHook( $top_category, array( 'mode' => 'categories', 'depth' => 10, 'hideroot' => $hideroot ) );
 1501+ $tree = efCategoryTreeParserHook( $top_category,
 1502+ array(
 1503+ 'mode' => 'categories',
 1504+ 'namespaces' => array( NS_CATEGORY ),
 1505+ 'depth' => 10,
 1506+ 'hideroot' => $hideroot,
 1507+ )
 1508+ );
14971509
14981510 // Capitalize the first letter, if first letters always get
14991511 // capitalized.
@@ -1582,7 +1594,14 @@
15831595
15841596 global $wgCategoryTreeMaxDepth;
15851597 $wgCategoryTreeMaxDepth = 10;
1586 - $tree = efCategoryTreeParserHook( $top_category, array( 'mode' => 'categories', 'depth' => 10, 'hideroot' => $hideroot ) );
 1598+ $tree = efCategoryTreeParserHook(
 1599+ $top_category, array(
 1600+ 'mode' => 'categories',
 1601+ 'namespaces' => array( NS_CATEGORY ),
 1602+ 'depth' => 10,
 1603+ 'hideroot' => $hideroot,
 1604+ )
 1605+ );
15871606 // Some string that will hopefully never show up in a category,
15881607 // template or field name.
15891608 $dummy_str = 'REPLACE THIS STRING!';

Comments

#Comment by Nikerabbit (talk | contribs)   14:48, 1 July 2011

You can also use Html::element which knows which tags need to be closed always.

What is the other fix? I see only white-space change.

#Comment by Yaron Koren (talk | contribs)   05:18, 3 July 2011

I'm not surprised that Html::element is better, but SF is still, for better or for worse, supporting versions of MediaWiki before the Html class was added (whatever version that was - I don't remember). Eventually, all the calls to Xml will be replaced by Html.

The other fix was adding the 'namespaces' parameter to efCategoryTreeParserHook().