r63906 MediaWiki - Code Review archive
Repository:
MediaWiki
Revision:
<
r63905
|
r63906
|
r63907
>
Date:
11:35, 18 March 2010
Author:
ialex
Status:
ok
Tags:
Comment:
* (
bug 22866
) Cast returned value to numeric if possible to do the check since ExprParser::doExpression() returns a string, this was causing some bugs since "-0" (string) converted to boolean is "true"
Modified paths:
/trunk/extensions/ParserFunctions/ParserFunctions_body.php
(modified) (
history
)
Diff
[
purge
]
Index: trunk/extensions/ParserFunctions/ParserFunctions_body.php
—
—
@@ -67,7 +67,11 @@
68
68
69
69
function ifexpr( &$parser, $expr = '', $then = '', $else = '' ) {
70
70
try{
71
- if($this->getExprParser()->doExpression( $expr )) {
71
+ $ret = $this->getExprParser()->doExpression( $expr );
72
+ if ( is_numeric( $ret ) ) {
73
+ $ret = floatval( $ret );
74
+ }
75
+ if( $ret ) {
72
76
return $then;
73
77
} else {
74
78
return $else;
Follow-up revisions
Revision
Commit summary
Author
Date
r63913
Follow-up
r63906
: add test case
ialex
16:31, 18 March 2010
Status & tagging log
00:41, 14 January 2011
Reedy
(
talk
|
contribs
)
changed the
status
of r63906
[
removed:
new
added:
ok]