Index: trunk/phase3/includes/api/ApiQueryAllmessages.php |
— | — | @@ -43,12 +43,11 @@ |
44 | 44 | public function execute() { |
45 | 45 | $params = $this->extractRequestParams(); |
46 | 46 | |
47 | | - global $wgLang; |
48 | | - |
49 | | - $oldLang = null; |
50 | | - if ( !is_null( $params['lang'] ) ) { |
51 | | - $oldLang = $wgLang; // Keep $wgLang for restore later |
52 | | - $wgLang = Language::factory( $params['lang'] ); |
| 47 | + if ( is_null( $params['lang'] ) ) { |
| 48 | + global $wgLang; |
| 49 | + $langObj = $wgLang; |
| 50 | + } else { |
| 51 | + $langObj = Language::factory( $params['lang'] ); |
53 | 52 | } |
54 | 53 | |
55 | 54 | $prop = array_flip( (array)$params['prop'] ); |
— | — | @@ -90,32 +89,29 @@ |
91 | 90 | |
92 | 91 | if ( !$skip ) { |
93 | 92 | $a = array( 'name' => $message ); |
94 | | - $args = null; |
| 93 | + $args = array(); |
95 | 94 | if ( isset( $params['args'] ) && count( $params['args'] ) != 0 ) { |
96 | 95 | $args = $params['args']; |
97 | 96 | } |
98 | | - // Check if the parser is enabled: |
99 | | - if ( $params['enableparser'] ) { |
100 | | - $msg = wfMsgExt( $message, array( 'parsemag' ), $args ); |
101 | | - } elseif ( $args ) { |
102 | | - $msgString = wfMsgGetKey( $message, true, false, false ); |
103 | | - $msg = wfMsgReplaceArgs( $msgString, $args ); |
104 | | - } else { |
105 | | - $msg = wfMsgGetKey( $message, true, false, false ); |
106 | | - } |
107 | 97 | |
108 | | - if ( wfEmptyMsg( $message, $msg ) ) { |
| 98 | + $msg = wfMessage( $message, $args )->inLanguage( $langObj ); |
| 99 | + |
| 100 | + if ( !$msg->exists() ) { |
109 | 101 | $a['missing'] = ''; |
110 | 102 | } else { |
111 | | - ApiResult::setContent( $a, $msg ); |
| 103 | + // Check if the parser is enabled: |
| 104 | + if ( $params['enableparser'] ) { |
| 105 | + $msgString = $msg->text(); |
| 106 | + } else { |
| 107 | + $msgString = $msg->plain(); |
| 108 | + } |
| 109 | + ApiResult::setContent( $a, $msgString ); |
112 | 110 | if ( isset( $prop['default'] ) ) { |
113 | | - $default = wfMsgGetKey( $message, false, false, false ); |
114 | | - if ( $default !== $msg ) { |
115 | | - if ( wfEmptyMsg( $message, $default ) ) { |
116 | | - $a['defaultmissing'] = ''; |
117 | | - } else { |
118 | | - $a['default'] = $default; |
119 | | - } |
| 111 | + $default = wfMessage( $message )->inLanguage( $langObj )->useDatabase( false ); |
| 112 | + if ( !$default->exists() ) { |
| 113 | + $a['defaultmissing'] = ''; |
| 114 | + } elseif ( $default->plain() != $msgString ) { |
| 115 | + $a['default'] = $default->plain(); |
120 | 116 | } |
121 | 117 | } |
122 | 118 | } |
— | — | @@ -127,10 +123,6 @@ |
128 | 124 | } |
129 | 125 | } |
130 | 126 | $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'message' ); |
131 | | - |
132 | | - if ( !is_null( $oldLang ) ) { |
133 | | - $wgLang = $oldLang; // Restore $oldLang |
134 | | - } |
135 | 127 | } |
136 | 128 | |
137 | 129 | public function getCacheMode( $params ) { |