Index: trunk/extensions/Translate/utils/TranslationHelpers.php |
— | — | @@ -237,6 +237,14 @@ |
238 | 238 | $path .= wfArrayToCgi( $query ); |
239 | 239 | $google_json = Http::get( $path, 2 ); |
240 | 240 | $response = json_decode( $google_json ); |
| 241 | + if ( $google_json === false ) { |
| 242 | + wfWarn( __METHOD__ . ': Http::get failed' ); |
| 243 | + return null; |
| 244 | + } elseif( !is_object( $response ) ) { |
| 245 | + wfWarn( __METHOD__ . ': Unable to parse reply: ' . strval( $google_json ) ); |
| 246 | + error_log( __METHOD__ . ': Unable to parse reply: ' . strval( $google_json ) ); |
| 247 | + return null; |
| 248 | + } |
241 | 249 | if ( $response->responseStatus === 200 ) { |
242 | 250 | $text = $this->suggestionField( $response->responseData->translatedText ); |
243 | 251 | return Html::rawElement( 'div', null, self::legend('Google') . $text . self::clear() ); |
— | — | @@ -246,7 +254,7 @@ |
247 | 255 | } else { |
248 | 256 | wfWarn( __METHOD__ . ': ' . $response->responseDetails ); |
249 | 257 | error_log( __METHOD__ . ': ' . $response->responseDetails ); |
250 | | - return false; |
| 258 | + return null; |
251 | 259 | } |
252 | 260 | } |
253 | 261 | |