r63905 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63904‎ | r63905 | r63906 >
Date:07:31, 18 March 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Enforce Google api size limit clientside

Now if the text is too long, the suggestion is not asked at all.
Anoter option would be truncating it.
Modified paths:
  • /trunk/extensions/Translate/utils/TranslationHelpers.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/utils/TranslationHelpers.php
@@ -218,13 +218,16 @@
219219 global $wgProxyKey, $wgGoogleApiKey, $wgMemc;
220220
221221 $code = $this->targetLanguage;
222 - $definition = $this->getDefinition();
 222+ $definition = trim( strval( $this->getDefinition() ) ) ;
223223
224224 $memckey = wfMemckey( 'translate-tmsug-badcodes' );
225225 $unsupported = $wgMemc->get( $memckey );
226226
227227 if ( isset( $unsupported[$code] ) ) return null;
228 - if ( trim( strval( $definition ) ) === '' ) return null;
 228+ if ( $definition === '' ) return null;
 229+ /* There is 5000 *character* limit, but encoding needs to be taken into
 230+ * account. Not sure if this applies also to post method. */
 231+ if ( strlen( rawurlencode( $definition ) ) > 4900 ) return null;
229232
230233 $path = 'http://ajax.googleapis.com/ajax/services/language/translate';
231234 $options = array();

Status & tagging log