r108046 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108045‎ | r108046 | r108047 >
Date:16:15, 4 January 2012
Author:nikerabbit
Status:ok
Tags:
Comment:
It's useful to catch the errors we might throw, ping r108034
Modified paths:
  • /trunk/extensions/Translate/utils/MessageIndex.php (modified) (history)
  • /trunk/extensions/Translate/utils/TranslationHelpers.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/utils/MessageIndex.php
@@ -35,7 +35,7 @@
3636
3737
3838 /**
39 - * @since 2012-01-14
 39+ * @since 2012-01-04
4040 * @return array
4141 */
4242 public static function getGroupIds( MessageHandle $handle ) {
@@ -52,7 +52,7 @@
5353 }
5454
5555 /**
56 - * @since 2012-01-14
 56+ * @since 2012-01-04
5757 * @return MessageGroup|null
5858 */
5959 public static function getPrimaryGroupId( MessageHandle $handle ) {
Index: trunk/extensions/Translate/utils/TranslationHelpers.php
@@ -193,11 +193,11 @@
194194 if ( $suggestions === 'async' ) {
195195 $all['translation-memory'] = array( $this, 'getLazySuggestionBox' );
196196 } elseif ( $suggestions === 'only' ) {
197 - return (string) call_user_func( $all['translation-memory'], 'lazy' );
 197+ return (string) $this->callBox( 'translation-memory', $all['translation-memory'], array( 'lazy' ) );
198198 } elseif ( $suggestions === 'checks' ) {
199199 global $wgRequest;
200200 $this->translation = $wgRequest->getText( 'translation' );
201 - return (string) call_user_func( $all['check'] );
 201+ return (string) $this->callBox( $all['check'], 'check' );
202202 }
203203
204204 if ( $this->group instanceof RecentMessageGroup ) {
@@ -206,12 +206,7 @@
207207
208208 $boxes = array();
209209 foreach ( $all as $type => $cb ) {
210 - try {
211 - $box = call_user_func( $cb );
212 - } catch ( TranslationHelperExpection $e ) {
213 - $box = "<!-- Box $type not available: {$e->getMessage()} -->";
214 - }
215 -
 210+ $box = $this->callBox( $type, $cb );
216211 if ( $box ) {
217212 $boxes[$type] = $box;
218213 }
@@ -224,6 +219,15 @@
225220 }
226221 }
227222
 223+ /// @since 2012-01-04
 224+ protected function callBox( $type, $cb, $params = array() ) {
 225+ try {
 226+ return call_user_func_array( $cb, $params );
 227+ } catch ( TranslationHelperExpection $e ) {
 228+ return"<!-- Box $type not available: {$e->getMessage()} -->";
 229+ }
 230+ }
 231+
228232 /**
229233 * @return array
230234 */

Follow-up revisions

RevisionCommit summaryAuthorDate
r108048Fix buggy refactoring, ping r108046nikerabbit16:23, 4 January 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r108034* Refactored TranslationHelpers to have MessageHandle as store variable, inst...nikerabbit15:13, 4 January 2012

Status & tagging log