Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Quantity.php |
— | — | @@ -27,6 +27,7 @@ |
28 | 28 | $this->initConversionData(); |
29 | 29 | if ( array_key_exists( $unit, $this->m_unitids ) ) { |
30 | 30 | $this->m_unitin = $this->m_unitids[$unit]; |
| 31 | + assert( '$this->m_unitfactors[$this->m_unitin] != 0 /* Should be filtered by initConversionData() */' ); |
31 | 32 | $this->m_dataitem = new SMWDINumber( $number / $this->m_unitfactors[$this->m_unitin], $this->m_typeid ); |
32 | 33 | return true; |
33 | 34 | } else { // unsupported unit |
— | — | @@ -132,7 +133,8 @@ |
133 | 134 | $number = $unit = ''; |
134 | 135 | foreach ( $factors as $di ) { |
135 | 136 | if ( ( $di->getDIType() !== SMWDataItem::TYPE_STRING ) || |
136 | | - ( SMWNumberValue::parseNumberValue( $di->getString(), $number, $unit ) != 0 ) ) { |
| 137 | + ( SMWNumberValue::parseNumberValue( $di->getString(), $number, $unit ) != 0 ) || |
| 138 | + ( $number == 0 ) ) { |
137 | 139 | continue; // ignore corrupted data and bogus inputs |
138 | 140 | } |
139 | 141 | $unit_aliases = preg_split( '/\s*,\s*/u', $unit ); |