Nicer way of doing r78566, and also one which won't incur Tim's wrath... :D
authorHappy-melon <happy-melon@users.mediawiki.org>
Sat, 18 Dec 2010 19:08:22 +0000 (19:08 +0000)
committerHappy-melon <happy-melon@users.mediawiki.org>
Sat, 18 Dec 2010 19:08:22 +0000 (19:08 +0000)
includes/HTMLForm.php

index fbb17d4..8bed092 100644 (file)
@@ -1222,16 +1222,18 @@ class HTMLSelectField extends HTMLFormField {
                # If one of the options' 'name' is int(0), it is automatically selected.
                # because PHP sucks and things int(0) == 'some string'.
                # Working around this by forcing all of them to strings.
-               $options = array_map( 
-                       create_function('$opt', 'return is_int($opt) ? strval($opt) : $opt;'),
-                       $this->mParams['options'] 
-               );
+               foreach( $this->mParams['options'] as $key => &$opt ){
+                       if( is_int( $opt ) ){
+                               $opt = strval( $opt );
+                       }
+               }
+               unset( $opt ); # PHP keeps $opt around as a reference, which is a bit scary
 
                if ( !empty( $this->mParams['disabled'] ) ) {
                        $select->setAttribute( 'disabled', 'disabled' );
                }
 
-               $select->addOptions( $options );
+               $select->addOptions( $this->mParams['options'] );
 
                return $select->getHTML();
        }