diff --git a/ParserFunctions_body.php b/ParserFunctions_body.php index 1e7a4c66..789d0c4f 100644 --- a/ParserFunctions_body.php +++ b/ParserFunctions_body.php @@ -187,7 +187,7 @@ class ExtParserFunctions { return ''; } $primary = trim( $frame->expand( array_shift( $args ) ) ); - $found = false; + $found = $defaultFound = false; $default = null; $lastItemHadNoEquals = false; $mwDefault =& MagicWord::get( 'default' ); @@ -209,7 +209,7 @@ class ExtParserFunctions { if ( $test == $primary ) { # Found a match, return now return trim( $frame->expand( $valueNode ) ); - } elseif ( $mwDefault->matchStartAndRemove( $test ) ) { + } elseif ( $defaultFound || $mwDefault->matchStartAndRemove( $test ) ) { $default = $valueNode; } # else wrong case, continue } @@ -220,6 +220,8 @@ class ExtParserFunctions { $test = trim( $frame->expand( $valueNode ) ); if ( $test == $primary ) { $found = true; + } elseif ( $mwDefault->matchStartAndRemove( $test ) ) { + $defaultFound = true; } } } diff --git a/funcsParserTests.txt b/funcsParserTests.txt index f0500204..b6a0f282 100644 --- a/funcsParserTests.txt +++ b/funcsParserTests.txt @@ -41,3 +41,14 @@ Time test after the 2038 32-bit Apocalype
2061
!! end + +!! test +Bug 19093: Default values don't fall through in switch +!! input +<{{#switch: foo | bar | #default = DEF }}> +<{{#switch: foo | #default | bar = DEF }}> +!! result +<DEF> +<DEF> +
+!! end