r75485 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75484‎ | r75485 | r75486 >
Date:23:02, 26 October 2010
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Remove unused variables, few other tweaks and bits and pieces
Modified paths:
  • /trunk/extensions/Translate/FFS.php (modified) (history)
  • /trunk/extensions/Translate/MessageGroups.php (modified) (history)
  • /trunk/extensions/Translate/SpecialImportTranslations.php (modified) (history)
  • /trunk/extensions/Translate/SpecialLanguageStats.php (modified) (history)
  • /trunk/extensions/Translate/SpecialMagic.php (modified) (history)
  • /trunk/extensions/Translate/SpecialManageGroups.php (modified) (history)
  • /trunk/extensions/Translate/SpecialTranslationChanges.php (modified) (history)
  • /trunk/extensions/Translate/SpecialTranslations.php (modified) (history)
  • /trunk/extensions/Translate/TranslateEditAddons.php (modified) (history)
  • /trunk/extensions/Translate/TranslatePage.php (modified) (history)
  • /trunk/extensions/Translate/TranslateUtils.php (modified) (history)
  • /trunk/extensions/Translate/api/ApiQueryMessageGroups.php (modified) (history)
  • /trunk/extensions/Translate/ffs/Gettext.php (modified) (history)
  • /trunk/extensions/Translate/ffs/PhpVariables.php (modified) (history)
  • /trunk/extensions/Translate/ffs/Simple.php (modified) (history)
  • /trunk/extensions/Translate/ffs/WikiExtension.php (modified) (history)
  • /trunk/extensions/Translate/groups/ComplexMessages.php (modified) (history)
  • /trunk/extensions/Translate/groups/StatusNet/genStatusNet-plugins.php (modified) (history)
  • /trunk/extensions/Translate/scripts/cldr-plural-to-yaml.php (modified) (history)
  • /trunk/extensions/Translate/scripts/magic-export.php (modified) (history)
  • /trunk/extensions/Translate/scripts/pagetranslation-check-database.php (modified) (history)
  • /trunk/extensions/Translate/spyc/spyc.php (modified) (history)
  • /trunk/extensions/Translate/tag/SpecialPageTranslation.php (modified) (history)
  • /trunk/extensions/Translate/tag/TranslatablePage.php (modified) (history)
  • /trunk/extensions/Translate/utils/MessageWebImporter.php (modified) (history)
  • /trunk/extensions/Translate/utils/TranslationEditPage.php (modified) (history)
  • /trunk/extensions/Translate/utils/TranslationHelpers.php (modified) (history)
  • /trunk/extensions/Translate/utils/TranslationMemoryUpdater.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/SpecialManageGroups.php
@@ -155,10 +155,10 @@
156156
157157 $this->out->addHTML(
158158 Xml::openElement( 'form', $formParams ) .
159 - Xml::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
160 - Xml::hidden( 'token', $this->user->editToken() ) .
161 - Xml::hidden( 'group', $group->getId() ) .
162 - Xml::hidden( 'process', 1 )
 159+ Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
 160+ Html::hidden( 'token', $this->user->editToken() ) .
 161+ Html::hidden( 'group', $group->getId() ) .
 162+ Html::hidden( 'process', 1 )
163163 );
164164
165165 // BEGIN
@@ -330,7 +330,7 @@
331331 $lang = TranslateUtils::getLanguageName( $code, false, $wgLang->getCode() );
332332 $this->out->addWikiMsg( 'translate-manage-intro-other', $lang );
333333 }
334 - $this->out->addHTML( Xml::hidden( 'language', $code ) );
 334+ $this->out->addHTML( Html::hidden( 'language', $code ) );
335335 $this->out->addHTML( implode( "\n", $changed ) );
336336 $this->out->addHTML( Xml::submitButton( wfMsg( 'translate-manage-submit' ) ) );
337337 } else {
@@ -398,11 +398,11 @@
399399
400400 $this->out->addHTML(
401401 Xml::openElement( 'form', $formParams ) .
402 - Xml::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
403 - Xml::hidden( 'token', $this->user->editToken() ) .
404 - Xml::hidden( 'group', $group->getId() ) .
405 - Xml::hidden( 'codes', implode( ',', $codes ) ) .
406 - Xml::hidden( 'rebuildall', 1 ) .
 402+ Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
 403+ Html::hidden( 'token', $this->user->editToken() ) .
 404+ Html::hidden( 'group', $group->getId() ) .
 405+ Html::hidden( 'codes', implode( ',', $codes ) ) .
 406+ Html::hidden( 'rebuildall', 1 ) .
407407 Xml::submitButton( wfMsg( 'translate-manage-import-rebuild-all' ) ) .
408408 Xml::closeElement( 'form' )
409409 );
Index: trunk/extensions/Translate/TranslatePage.php
@@ -31,7 +31,7 @@
3232 * Access point for this special page.
3333 */
3434 public function execute( $parameters ) {
35 - global $wgOut, $wgTranslateBlacklist, $wgUser, $wgRequest;
 35+ global $wgOut, $wgTranslateBlacklist, $wgRequest;
3636
3737 TranslateUtils::injectCSS();
3838
@@ -193,10 +193,6 @@
194194 protected function settingsForm( $errors ) {
195195 global $wgScript;
196196
197 - $task = $this->taskSelector();
198 - $group = $this->groupSelector();
199 - $language = $this->languageSelector();
200 - $limit = $this->limitSelector();
201197 $button = Xml::submitButton( wfMsg( 'translate-submit' ) );
202198
203199 $options = array();
@@ -213,7 +209,7 @@
214210 Xml::openElement( 'fieldset', array( 'class' => 'mw-sp-translate-settings' ) ) .
215211 Xml::element( 'legend', null, wfMsg( 'translate-page-settings-legend' ) ) .
216212 Xml::openElement( 'form', array( 'action' => $wgScript, 'method' => 'get' ) ) .
217 - Xml::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
 213+ Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
218214 Xml::openElement( 'table' ) .
219215 implode( "", $options ) .
220216 self::optionRow( $button, ' ' ) .
Index: trunk/extensions/Translate/scripts/magic-export.php
@@ -263,7 +263,7 @@
264264 protected function writeFooters() {
265265 $this->output( "Writing file footers...\n" );
266266 if( $this->type === 'special' ) {
267 - foreach( $this->handles as $group => $handle ) {
 267+ foreach( $this->handles as $handle ) {
268268 fwrite( $handle, <<<PHP
269269
270270
@@ -282,7 +282,7 @@
283283 */
284284 protected function closeHandles() {
285285 $this->output( "Closing file handles...\n" );
286 - foreach ( $this->handles as $group => $handle ) {
 286+ foreach ( $this->handles as $handle ) {
287287 fclose( $handle );
288288 }
289289 }
Index: trunk/extensions/Translate/scripts/cldr-plural-to-yaml.php
@@ -35,7 +35,7 @@
3636 $doc->load( 'plurals.xml' );
3737
3838 $rulesets = $doc->getElementsByTagName( "pluralRules" );
39 - foreach( $rulesets as $index => $ruleset ) {
 39+ foreach( $rulesets as $ruleset ) {
4040 $codes = $ruleset->getAttribute( 'locales' );
4141 $parsed = array();
4242 $rules = $ruleset->getElementsByTagName( "pluralRule" );
Index: trunk/extensions/Translate/scripts/pagetranslation-check-database.php
@@ -121,7 +121,6 @@
122122 $title = Title::newFromID( $id );
123123 $name = $title ? $title->getPrefixedText() : "#$id";
124124
125 -
126125 if ( !$title ) {
127126 $name = "#$id";
128127 $deleted = $this->findDeletedPage( $id );
Index: trunk/extensions/Translate/SpecialLanguageStats.php
@@ -78,7 +78,7 @@
7979
8080 $out = Xml::openElement( 'div', array( 'class' => 'languagecode' ) );
8181 $out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
82 - $out .= Xml::hidden( 'title', $t->getPrefixedText() );
 82+ $out .= Html::hidden( 'title', $t->getPrefixedText() );
8383 $out .= Xml::openElement( 'fieldset' );
8484 $out .= Xml::element( 'legend', null, wfMsg( 'translate-language-code' ) );
8585 $out .= Xml::openElement( 'table', array( 'id' => 'langcodeselect', 'class' => 'allpages' ) );
@@ -198,7 +198,7 @@
199199 * @return \string HTML
200200 */
201201 function getGroupStats( $code, $suppressComplete = false ) {
202 - global $wgUser, $wgLang, $wgOut;
 202+ global $wgLang;
203203
204204 $out = '';
205205
@@ -302,7 +302,9 @@
303303 $cache->set( $group->getId(), $code, $result );
304304
305305 static $i = 0;
306 - if ( $i++ % 50 === 0 ) $cache->commit();
 306+ if ( $i++ % 50 === 0 ) {
 307+ $cache->commit();
 308+ }
307309
308310 return $result;
309311 }
Index: trunk/extensions/Translate/SpecialImportTranslations.php
@@ -133,8 +133,8 @@
134134 'enctype' => 'multipart/form-data',
135135 'id' => 'mw-translate-import',
136136 ) ) .
137 - Xml::hidden( 'token', $this->user->editToken() ) .
138 - Xml::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
 137+ Html::hidden( 'token', $this->user->editToken() ) .
 138+ Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
139139 Xml::openElement( 'table' ) .
140140 Xml::openElement( 'tr' ) .
141141 Xml::openElement( 'td' )
Index: trunk/extensions/Translate/FFS.php
@@ -709,8 +709,6 @@
710710 class YamlFFS extends SimpleFFS {
711711
712712 public function readFromVariable( $data ) {
713 - $authors = $messages = array();
714 -
715713 // Authors first.
716714 $matches = array();
717715 preg_match_all( '/^#\s*Author:\s*(.*)$/m', $data, $matches );
Index: trunk/extensions/Translate/MessageGroups.php
@@ -813,7 +813,9 @@
814814 /// Initialises the list of groups (but not the groups itself if possible).
815815 public static function init() {
816816 static $loaded = false;
817 - if ( $loaded ) return;
 817+ if ( $loaded ) {
 818+ return;
 819+ }
818820 $loaded = true;
819821
820822 global $wgTranslateCC, $wgTranslateEC, $wgTranslateAC;
@@ -872,7 +874,7 @@
873875 global $wgTranslateAddMWExtensionGroups;
874876 global $wgEnablePageTranslation, $wgTranslateGroupFiles;
875877 global $wgTranslateAC, $wgTranslateEC, $wgTranslateCC;
876 - global $wgAutoloadClasses, $wgTranslateExtensionDirectory;
 878+ global $wgAutoloadClasses;
877879
878880 $deps = array();
879881 $deps[] = new GlobalDependency( 'wgTranslateAddMWExtensionGroups' );
Index: trunk/extensions/Translate/tag/TranslatablePage.php
@@ -674,7 +674,7 @@
675675 }
676676
677677 $codes = Language::getLanguageNames( false );
678 - global $wgTranslateDocumentationLanguageCode, $wgContLang;
 678+ global $wgTranslateDocumentationLanguageCode;
679679 unset( $codes[$wgTranslateDocumentationLanguageCode] );
680680
681681 if ( !isset( $codes[$code] ) ) {
Index: trunk/extensions/Translate/tag/SpecialPageTranslation.php
@@ -362,10 +362,10 @@
363363
364364 $wgOut->addHTML(
365365 Xml::openElement( 'form', $formParams ) .
366 - Xml::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
367 - Xml::hidden( 'revision', $page->getRevision() ) .
368 - Xml::hidden( 'target', $page->getTitle()->getPrefixedtext() ) .
369 - Xml::hidden( 'token', $this->user->editToken() )
 366+ Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
 367+ Html::hidden( 'revision', $page->getRevision() ) .
 368+ Html::hidden( 'target', $page->getTitle()->getPrefixedtext() ) .
 369+ Html::hidden( 'token', $this->user->editToken() )
370370 );
371371
372372 $wgOut->wrapWikiMsg( '==$1==', 'tpt-sections-oldnew' );
Index: trunk/extensions/Translate/SpecialTranslationChanges.php
@@ -55,7 +55,7 @@
5656 'action' => $wgScript,
5757 'method' => 'get'
5858 ),
59 - Xml::hidden( 'title', $this->getTitle()->getPrefixedText() ) . $limit . $button
 59+ Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . $limit . $button
6060 );
6161 return $form;
6262 }
@@ -137,7 +137,7 @@
138138 $userLang = $wgLang->getCode();
139139
140140 $changes = $this->sort( $rows );
141 - foreach ( $changes as $class => $groups ) {
 141+ foreach ( $changes as $groups ) {
142142 foreach ( $groups as $group => $languages ) {
143143 $label = $group;
144144
Index: trunk/extensions/Translate/groups/ComplexMessages.php
@@ -418,7 +418,7 @@
419419 $this->validate( $errors, $filter );
420420 foreach ( $errors as $_ ) $text .= "#!!# $_\n";
421421
422 - foreach ( $groups = $this->getGroups() as $group => $data ) {
 422+ foreach ( $this->getGroups() as $group => $data ) {
423423 if ( $filter !== false && !in_array( $group, (array) $filter, true ) ) {
424424 continue;
425425 }
@@ -579,7 +579,7 @@
580580 foreach ( $this->getIterator( $group ) as $key ) {
581581 $values = $this->val( $group, self::LANG_CURRENT, $key );
582582
583 - foreach ( $values as $i => $_ ) {
 583+ foreach ( $values as $_ ) {
584584 wfSuppressWarnings();
585585 $title = SpecialPage::getTitleFor( $_ );
586586 wfRestoreWarnings();
Index: trunk/extensions/Translate/groups/StatusNet/genStatusNet-plugins.php
@@ -24,8 +24,7 @@
2525 global $plugins;
2626
2727 $path = rtrim( str_replace( "\\", "/", $path ), '/' ) . '/';
28 - $matches = Array();
29 - $entries = Array();
 28+ $entries = array();
3029 $dir = dir( $path );
3130 while ( false !== ( $entry = $dir->read() ) ) {
3231 $entries[] = $entry;
Index: trunk/extensions/Translate/TranslateEditAddons.php
@@ -44,12 +44,20 @@
4545
4646 $next = $prev = null;
4747 foreach ( $keys as $index => $tkey ) {
48 - if ( $key === strtolower( strtr( $tkey, ' ', '_' ) ) ) break;
49 - if ( $index === $count -1 ) $index = -666;
 48+ if ( $key === strtolower( strtr( $tkey, ' ', '_' ) ) ) {
 49+ break;
 50+ }
 51+ if ( $index === $count -1 ) {
 52+ $index = -666;
 53+ }
5054 }
5155
52 - if ( isset( $keys[$index-1] ) ) $prev = $keys[$index-1];
53 - if ( isset( $keys[$index+1] ) ) $next = $keys[$index+1];
 56+ if ( isset( $keys[$index-1] ) ) {
 57+ $prev = $keys[$index-1];
 58+ }
 59+ if ( isset( $keys[$index+1] ) ) {
 60+ $next = $keys[$index+1];
 61+ }
5462
5563
5664 $id = $group->getId();
@@ -291,8 +299,8 @@
292300 global $wgRequest;
293301
294302 $out->addHTML( "\n" .
295 - Xml::hidden( 'loadgroup', $wgRequest->getText( 'loadgroup' ) ) .
296 - Xml::hidden( 'loadtask', $wgRequest->getText( 'loadtask' ) ) .
 303+ Html::hidden( 'loadgroup', $wgRequest->getText( 'loadgroup' ) ) .
 304+ Html::hidden( 'loadtask', $wgRequest->getText( 'loadtask' ) ) .
297305 "\n"
298306 );
299307
Index: trunk/extensions/Translate/utils/TranslationEditPage.php
@@ -90,16 +90,16 @@
9191 $textarea = Html::element( 'textarea', $textareaParams, $translation );
9292
9393 $hidden = array();
94 - $hidden[] = Xml::hidden( 'title', $this->getTitle()->getPrefixedDbKey() );
 94+ $hidden[] = Html::hidden( 'title', $this->getTitle()->getPrefixedDbKey() );
9595
9696 if ( isset( $data['revisions'][0]['timestamp'] ) ) {
97 - $hidden[] = Xml::hidden( 'basetimestamp', $data['revisions'][0]['timestamp'] );
 97+ $hidden[] = Html::hidden( 'basetimestamp', $data['revisions'][0]['timestamp'] );
9898 }
9999
100 - $hidden[] = Xml::hidden( 'starttimestamp', $data['starttimestamp'] );
101 - $hidden[] = Xml::hidden( 'token', $data['edittoken'] );
102 - $hidden[] = Xml::hidden( 'format', 'json' );
103 - $hidden[] = Xml::hidden( 'action', 'edit' );
 100+ $hidden[] = Html::hidden( 'starttimestamp', $data['starttimestamp'] );
 101+ $hidden[] = Html::hidden( 'token', $data['edittoken'] );
 102+ $hidden[] = Html::hidden( 'format', 'json' );
 103+ $hidden[] = Html::hidden( 'action', 'edit' );
104104
105105 $summary = Xml::inputLabel( wfMsg( 'summary' ), 'summary', 'summary', 40 );
106106 $save = Xml::submitButton( wfMsg( 'savearticle' ), array( 'style' => 'font-weight:bold', 'class' => 'mw-translate-save' ) );
Index: trunk/extensions/Translate/utils/MessageWebImporter.php
@@ -83,9 +83,9 @@
8484
8585 return
8686 Xml::openElement( 'form', $formParams ) .
87 - Xml::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
88 - Xml::hidden( 'token', $this->getUser()->editToken() ) .
89 - Xml::hidden( 'process', 1 );
 87+ Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
 88+ Html::hidden( 'token', $this->getUser()->editToken() ) .
 89+ Html::hidden( 'process', 1 );
9090 }
9191
9292 protected function doFooter() {
@@ -266,7 +266,7 @@
267267 $lang = TranslateUtils::getLanguageName( $code, false, $wgLang->getCode() );
268268 $this->out->addWikiMsg( 'translate-manage-intro-other', $lang );
269269 }
270 - $this->out->addHTML( Xml::hidden( 'language', $code ) );
 270+ $this->out->addHTML( Html::hidden( 'language', $code ) );
271271 $this->out->addHTML( implode( "\n", $changed ) );
272272 $this->out->addHTML( Xml::submitButton( wfMsg( 'translate-manage-submit' ) ) );
273273 } else {
Index: trunk/extensions/Translate/utils/TranslationMemoryUpdater.php
@@ -96,7 +96,7 @@
9797
9898 $database = null;
9999
100 - foreach ( $wgTranslateTranslationServices as $service => $config ) {
 100+ foreach ( $wgTranslateTranslationServices as $config ) {
101101 if ( $config['type'] === 'tmserver' && isset( $config['database'] ) ) {
102102 $database = $config['database'];
103103 break;
Index: trunk/extensions/Translate/utils/TranslationHelpers.php
@@ -433,7 +433,6 @@
434434 return null;
435435 }
436436
437 - global $wgSitename, $wgVersion, $wgProxyKey;
438437 $options = array();
439438 $options['timeout'] = $config['timeout'];
440439
@@ -764,12 +763,12 @@
765764 foreach ( $help as $type => $lines ) {
766765 if ( $type === ':' ) {
767766 $files = '';
768 - foreach ( $lines as $index => $line ) {
 767+ foreach ( $lines as $line ) {
769768 $files .= ' ' . preg_replace( '/([^ :]+):(\d+)/', $pattern, $line );
770769 }
771770 $out .= "<nowiki>#:</nowiki> $files<br />";
772771 } else {
773 - foreach ( $lines as $index => $line ) {
 772+ foreach ( $lines as $line ) {
774773 $out .= "<nowiki>#$type</nowiki> $line<br />";
775774 }
776775 }
@@ -1041,11 +1040,13 @@
10421041 /**
10431042 * Checks whether the given service has exceeded failure count */
10441043 public static function checkTranslationServiceFailure( $service ) {
1045 - global $wgMemc, $wgContLang;
 1044+ global $wgMemc;
10461045
10471046 $key = wfMemckey( "translate-service-$service" );
10481047 $value = $wgMemc->get( $key );
1049 - if ( !is_string( $value ) ) return false;
 1048+ if ( !is_string( $value ) ) {
 1049+ return false;
 1050+ }
10501051 list( $count, $failed ) = explode( '|', $value, 2 );
10511052
10521053 if ( $failed + ( 2 * self::$serviceFailurePeriod ) < wfTimestamp() ) {
Index: trunk/extensions/Translate/TranslateUtils.php
@@ -135,7 +135,7 @@
136136
137137 // Fetch results, prepare a batch link existence check query.
138138 $rows = array();
139 - while ( $row = $dbr->fetchObject( $res ) ) {
 139+ foreach( $res as $row ) {
140140 $rows[] = $row;
141141 }
142142 $dbr->freeResult( $res );
Index: trunk/extensions/Translate/SpecialMagic.php
@@ -77,7 +77,7 @@
7878 Xml::submitButton( wfMsg( self::MSG . 'submit' ) ) . ' ' .
7979 Xml::submitButton( wfMsg( 'translate-magic-cm-export' ), array( 'name' => 'export' ) ) .
8080 '</td></tr></table>' .
81 - Xml::hidden( 'title', $this->getTitle()->getPrefixedText() )
 81+ Html::hidden( 'title', $this->getTitle()->getPrefixedText() )
8282 );
8383 return $form;
8484 }
@@ -143,8 +143,9 @@
144144
145145 $wgOut->addHTML( $this->getForm() );
146146
147 - if ( !$this->options['module'] ) { return; }
148 - $o = null;
 147+ if ( !$this->options['module'] ) {
 148+ return;
 149+ }
149150 switch ( $this->options['module'] ) {
150151 case 'alias':
151152 case self::MODULE_SPECIAL:
Index: trunk/extensions/Translate/SpecialTranslations.php
@@ -33,8 +33,6 @@
3434
3535 self::includeAssets();
3636
37 - $title = null;
38 -
3937 if ( $this->including() ) {
4038 $title = Title::newFromText( $par );
4139 if ( !$title ) {
@@ -86,7 +84,7 @@
8785
8886 $out = Xml::openElement( 'div', array( 'class' => 'namespaceoptions' ) );
8987 $out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
90 - $out .= Xml::hidden( 'title', $t->getPrefixedText() );
 88+ $out .= Html::hidden( 'title', $t->getPrefixedText() );
9189 $out .= Xml::openElement( 'fieldset' );
9290 $out .= Xml::element( 'legend', null, wfMsg( 'translate-translations-fieldset-title' ) );
9391 $out .= Xml::openElement( 'table', array( 'id' => 'nsselect', 'class' => 'allpages' ) );
Index: trunk/extensions/Translate/api/ApiQueryMessageGroups.php
@@ -24,7 +24,6 @@
2525 }
2626
2727 public function execute() {
28 - $params = $this->extractRequestParams();
2928 $groups = MessageGroups::getAllGroups();
3029 $result = $this->getResult();
3130
@@ -39,7 +38,6 @@
4039 }
4140
4241 $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'group' );
43 -
4442 }
4543
4644 public function getDescription() {
Index: trunk/extensions/Translate/ffs/Simple.php
@@ -87,7 +87,6 @@
8888 $messages = array();
8989 $matches = array();
9090
91 - $match = array();
9291 preg_match_all( $this->messagePattern, $data, $matches, PREG_SET_ORDER );
9392 foreach ( $matches as $match ) {
9493 list( , $key, $value ) = $match;
Index: trunk/extensions/Translate/ffs/PhpVariables.php
@@ -18,8 +18,6 @@
1919 // READ
2020 //
2121 public function readFromVariable( $data ) {
22 - $authors = $messages = array();
23 -
2422 # Authors first
2523 $matches = array();
2624 preg_match_all( '/^ \* @author\s+(.+)$/m', $data, $matches );
Index: trunk/extensions/Translate/ffs/WikiExtension.php
@@ -48,7 +48,7 @@
4949
5050 $sections = array();
5151 $unknown = array();
52 - foreach ( $sectionMatches as $index => $data ) {
 52+ foreach ( $sectionMatches as $data ) {
5353 $code = array();
5454 if ( !preg_match( "~$codeP~xsu", $data[0], $code ) ) {
5555 echo "Malformed section:\n$data[0]";
Index: trunk/extensions/Translate/ffs/Gettext.php
@@ -26,8 +26,6 @@
2727 }
2828
2929 public function readFromVariable( $data ) {
30 - $authors = array();
31 -
3230 # Authors first
3331 $matches = array();
3432 preg_match_all( '/^#\s*Author:\s*(.*)$/m', $data, $matches );
Index: trunk/extensions/Translate/spyc/spyc.php
@@ -480,11 +480,14 @@
481481 * @param string $line A line from the YAML file
482482 */
483483 private function _parseLine($line) {
484 - if (!$line) return array();
 484+ if (!$line) {
 485+ return array();
 486+ }
485487 $line = trim($line);
486 - if (!$line) return array();
 488+ if (!$line) {
 489+ return array();
 490+ }
487491
488 - $array = array();
489492
490493 $group = $this->nodeContainsGroup($line);
491494 if ($group) {
@@ -693,7 +696,7 @@
694697 }
695698
696699 $finished = true;
697 - foreach ($explode as $key => $value) {
 700+ foreach ($explode as $value) {
698701 if (strpos($value,'YAMLSeq') !== false) {
699702 $finished = false; break;
700703 }
@@ -965,7 +968,6 @@
966969
967970 private function returnKeyValuePair ($line) {
968971 $array = array();
969 - $key = '';
970972 if (strpos ($line, ':')) {
971973 // It's a key/value pair most likely
972974 // If the key is in double quotes pull it out
@@ -987,10 +989,8 @@
988990 $array = array ($line);
989991 }
990992 return $array;
991 -
992993 }
993994
994 -
995995 private function returnArrayElement ($line) {
996996 if (strlen($line) <= 1) return array(array()); // Weird %)
997997 $array = array();

Follow-up revisions

RevisionCommit summaryAuthorDate
r75510Minor revert to r75485, add back some actually used variables used using 3442fooreedy10:55, 27 October 2010

Comments

#Comment by Aaron Schulz (talk | contribs)   23:52, 26 October 2010

What tool are you using btw?

#Comment by Hashar (talk | contribs)   08:05, 27 October 2010

Might be check-vars.php in /trunk/tools/code-utils/ by user:platonides

http://svn.wikimedia.org/viewvc/mediawiki/trunk/tools/code-utils/

#Comment by Reedy (talk | contribs)   08:42, 27 October 2010

Nope, it's PhpStorm, I'm using it as my full IDE

http://www.jetbrains.com/phpstorm/

Java based, and I have an "Open Source" license (free copy of the software for open source projects)

If you want a copy (I'd reccommend using their EAP's/Alphas), please let me know and I can forward the license to any MediaWiki developer

#Comment by Nikerabbit (talk | contribs)   10:57, 27 October 2010

Looks ok with the follow-up fix.

Status & tagging log