r52070 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52069‎ | r52070 | r52071 >
Date:19:08, 17 June 2009
Author:werdna
Status:ok
Tags:
Comment:
Fix for string/int inconsistency in value and option for imagesize, resulting in unintended preference reversion.
Modified paths:
  • /trunk/phase3/includes/HTMLForm.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/HTMLForm.php
@@ -601,13 +601,18 @@
602602 }
603603
604604 function getInputHTML( $value ) {
605 - $select = new XmlSelect( $this->mName, $this->mID, $value );
 605+ $select = new XmlSelect( $this->mName, $this->mID, strval($value) );
606606
 607+ // If one of the options' 'name' is int(0), it is automatically selected.
 608+ // because PHP sucks and things int(0) == 'some string'.
 609+ // Working around this by forcing all of them to strings.
 610+ $options = array_map( 'strval', $this->mParams['options'] );
 611+
607612 if (!empty($this->mParams['disabled'])) {
608613 $select->setAttribute( 'disabled', 'disabled' );
609614 }
610615
611 - $select->addOptions( $this->mParams['options'] );
 616+ $select->addOptions( $options );
612617
613618 return $select->getHTML();
614619 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r78566r52070 breaks the use of optgroups etc: array(...) is cast to 'Array'. Need ...happy-melon16:25, 18 December 2010

Status & tagging log