Page MenuHomePhabricator

webservice Yandex broken (YandexWebService::getQuery)
Closed, ResolvedPublic


I use Translate extension (MLEB 2017.07, MW 1.28.2) and as reported on the function YandexWebService::getQuery needs to be fixed like so:

protected function getQuery( $text, $from, $to ) {
  if ( !isset( $this->config['key'] ) ) {
    throw new TranslationWebServiceConfigurationException( 'API key is not set' );

  if ( strlen( $text ) > 10000 ) {
    throw new TranslationWebServiceInvalidInputException( 'Source text too long' );

  $text = trim( $text );
  $text = $this->wrapUntranslatable( $text );

  return TranslationQuery::factory( $this->config['url'] )
    ->timeout( $this->config['timeout'] )
        'key' => $this->config['key'],
        'text' => $text,
        'lang' => "$from-$to",
        'format' => 'html',

The bug is that in the TranslationQueryResponse Object the query:body is set but no query:parameters. There is also a misspelled typo but none of importance (paramater instead of parameter: TranslationQuery::queryParamaters)

Event Timeline

I am not sure whether that is the problem though. Cxserver has similar code and also there all the parameters are in the body:

		postData = {
			uri: + '/api/v1.5/tr.json/translate',
			proxy: this.conf.proxy,
			body: {
				lang: sourceLang + '-' + targetLang,
				format: 'html',
				text: sourceText

In Firefox Network console I find no request to the translation api of Yandex, but somehow it is done; I get only registered the localhost request of .../api.php?action=translationaids....

Is it possible to request manually an equivalent with curl to see which request returns correctly (of object have set TranslationQuery->query->body or object have set TranslationQuery->query->params) ?

The calls to Yandex are made server side. You would need to add debug statements to lower level of code to see the actual URL and parameters.