r52036 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52035‎ | r52036 | r52037 >
Date:09:50, 17 June 2009
Author:nikerabbit
Status:ok
Tags:
Comment:
Xml::element fails silently by creating only a opening element if the input is empty string, which is bad.
Modified paths:
  • /trunk/extensions/Translate/SpecialMagic.php (modified) (history)
  • /trunk/extensions/Translate/Translate.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/Translate.i18n.php
@@ -92,6 +92,8 @@
9393 'translate-magic-submit' => 'Fetch',
9494 'translate-magic-cm-export' => 'Export', // cm- should be removed
9595
 96+ 'translate-magic-nothing-to-export' => 'There is nothing to export.',
 97+
9698 'translate-magic-cm-to-be' => 'To-be',
9799 'translate-magic-cm-current' => 'Current',
98100 'translate-magic-cm-original' => 'Original',
Index: trunk/extensions/Translate/SpecialMagic.php
@@ -123,9 +123,6 @@
124124 $this->setup( $parameters );
125125 $this->setHeaders();
126126
127 - $wgOut->addHTML( $this->getForm() );
128 - $wgOut->addWikiMsg( self::MSG . 'help' );
129 -
130127 if ( !$this->options['module'] ) { return; }
131128 $o = null;
132129 switch ( $this->options['module'] ) {
@@ -139,24 +136,31 @@
140137 case self::MODULE_NAMESPACE:
141138 $o = new NamespaceCM( $this->options['language'] );
142139 break;
143 -
144140 default:
145 - return;
 141+ // OOps.
146142 }
147143
 144+ $wgOut->addHTML( $this->getForm() );
 145+
148146 if ( $wgRequest->wasPosted() && $this->options['savetodb'] ) {
149147 if ( !$wgUser->isAllowed( 'translate' ) ) {
150148 $wgOut->permissionRequired( 'translate' );
151 - return;
 149+ } else {
 150+ $o->save( $wgRequest );
152151 }
153 -
154 - $o->save( $wgRequest );
155152 }
156153
157154 if ( $o instanceof ComplexMessages ) {
158155 if ( $this->options['export'] ) {
159 - $result = Xml::element( 'textarea', array( 'rows' => '30' ) , $o->export() );
 156+ $output = $o->export();
 157+ if ( $output === '' ) {
 158+ $wgOut->addWikiMsg( 'translate-magic-nothing-to-export' );
 159+ return;
 160+ }
 161+ $result = Xml::element( 'textarea', array( 'rows' => '30' ), $output );
160162 } else {
 163+
 164+ $wgOut->addWikiMsg( self::MSG . 'help' );
161165 $result = $o->output();
162166 }
163167 }

Status & tagging log