r105748 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105747‎ | r105748 | r105749 >
Date:02:52, 10 December 2011
Author:danwe
Status:deferred
Tags:
Comment:
Re-created behavior on '{{#arraydefine:a|}}' from 1.3.2. Made it possible to create an array with a single empty element with the 'singleempty' option though.
Modified paths:
  • /trunk/extensions/Arrays/Arrays.php (modified) (history)
  • /trunk/extensions/Arrays/RELEASE-NOTES (modified) (history)

Diff [purge]

Index: trunk/extensions/Arrays/RELEASE-NOTES
@@ -3,6 +3,9 @@
44
55 * (trunk) -- Version 2.0rc3 alpha
66 - Adjusted to work with 'Regex Fun' version 1.1
 7+ - '{{#arraydefine: a |}}' will create an empty array instead of an array with an empty element as in
 8+ version 1.3.2. A new option 'singleempty' can be used to avoid this behavior, ',' can be used to
 9+ create an array with two empty elements.
710
811 * December 5, 2011 -- Version 2.0rc2
912 - Bug introduced in r105069 fixed where '#arrayprint' was broken in compatibility mode in some cases.
Index: trunk/extensions/Arrays/Arrays.php
@@ -181,8 +181,6 @@
182182 $array = array();
183183 }
184184 else {
185 - $value = trim( $value ); // just in case...
186 -
187185 // fill array with user input:
188186 if( $delimiter === '' ) {
189187 // whole input one element, also takes care of special case empty '' value and 'unique' option set
@@ -211,6 +209,15 @@
212210 // unique like the parser function would do it
213211 $array = self::array_unique( $array );
214212 }
 213+
 214+ // if 'singleempty' is NOT set, {{#arraydefine:a|}} will be empty.
 215+ // by default this would give an empty array (due to historical as well as usability reasons)
 216+ if( ! array_key_exists( 'singleempty', $arrayOptions ) ) {
 217+ // there is no other uncomplicated way than this to define a single empty elemented array currently!
 218+ if( count( $array ) === 1 && $array[0] === '' ) {
 219+ $array = array();
 220+ }
 221+ }
215222
216223 /**
217224 * @ToDo:

Status & tagging log