Index: trunk/phase3/maintenance/tests/phpunit/includes/MessageTest.php |
— | — | @@ -34,6 +34,13 @@ |
35 | 35 | $this->assertEquals( 'Заглавная страница', wfMessage( 'mainpage' )->inLanguage( Language::factory( 'ru' ) )->text() ); |
36 | 36 | } |
37 | 37 | |
| 38 | + function testMessagePararms() { |
| 39 | + $this->assertEquals( 'Return to $1.', wfMessage( 'returnto' )->text() ); |
| 40 | + $this->assertEquals( 'Return to $1.', wfMessage( 'returnto', array() )->text() ); |
| 41 | + $this->assertEquals( 'You have foo (bar).', wfMessage( 'youhavenewmessages', 'foo', 'bar' )->text() ); |
| 42 | + $this->assertEquals( 'You have foo (bar).', wfMessage( 'youhavenewmessages', array( 'foo', 'bar' ) )->text() ); |
| 43 | + } |
| 44 | + |
38 | 45 | /** |
39 | 46 | * @expectedException MWException |
40 | 47 | */ |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -609,6 +609,9 @@ |
610 | 610 | function wfMessage( $key /*...*/) { |
611 | 611 | $params = func_get_args(); |
612 | 612 | array_shift( $params ); |
| 613 | + if ( isset( $params[0] ) && is_array( $params[0] ) ) { |
| 614 | + $params = $params[0]; |
| 615 | + } |
613 | 616 | return new Message( $key, $params ); |
614 | 617 | } |
615 | 618 | |
— | — | @@ -1234,23 +1237,28 @@ |
1235 | 1238 | * @return bool Whereas client accept gzip compression |
1236 | 1239 | */ |
1237 | 1240 | function wfClientAcceptsGzip() { |
1238 | | - if( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) { |
1239 | | - # FIXME: we may want to blacklist some broken browsers |
1240 | | - $m = array(); |
1241 | | - if( preg_match( |
1242 | | - '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/', |
1243 | | - $_SERVER['HTTP_ACCEPT_ENCODING'], |
1244 | | - $m ) |
1245 | | - ) |
1246 | | - { |
1247 | | - if( isset( $m[2] ) && ( $m[1] == 'q' ) && ( $m[2] == 0 ) ) { |
1248 | | - return false; |
| 1241 | + static $result = null; |
| 1242 | + if ( $result === null ) { |
| 1243 | + $result = false; |
| 1244 | + if( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) { |
| 1245 | + # FIXME: we may want to blacklist some broken browsers |
| 1246 | + $m = array(); |
| 1247 | + if( preg_match( |
| 1248 | + '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/', |
| 1249 | + $_SERVER['HTTP_ACCEPT_ENCODING'], |
| 1250 | + $m ) |
| 1251 | + ) |
| 1252 | + { |
| 1253 | + if( isset( $m[2] ) && ( $m[1] == 'q' ) && ( $m[2] == 0 ) ) { |
| 1254 | + $result = false; |
| 1255 | + return $result; |
| 1256 | + } |
| 1257 | + wfDebug( " accepts gzip\n" ); |
| 1258 | + $result = true; |
1249 | 1259 | } |
1250 | | - wfDebug( " accepts gzip\n" ); |
1251 | | - return true; |
1252 | 1260 | } |
1253 | 1261 | } |
1254 | | - return false; |
| 1262 | + return $result; |
1255 | 1263 | } |
1256 | 1264 | |
1257 | 1265 | /** |