r53649 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53648‎ | r53649 | r53650 >
Date:16:37, 22 July 2009
Author:nikerabbit
Status:ok
Tags:
Comment:
Bugfixes:
* Don't bulk if group doesn't contain optional or ignored messages
* Non-existing files is not an exceptional case
* Return false if there is nothing to read
Modified paths:
  • /trunk/extensions/Translate/FFS.php (modified) (history)
  • /trunk/extensions/Translate/Groups.php (modified) (history)
  • /trunk/extensions/Translate/MessageCollection.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/MessageCollection.php
@@ -186,9 +186,14 @@
187187 } elseif( $filter === 'changed' ) {
188188 $keys = $this->filterChanged( $keys, $condition );
189189 } else { // Filter based on tags
190 - if ( !isset($this->tags[$filter]) ) throw new MWException( "No tagged messages for filter $filter" );
191 - $taggedKeys = array_flip( $this->tags[$filter] );
192 - $keys = $this->filterOnCondition( $keys, $taggedKeys, $condition );
 190+ if ( !isset($this->tags[$filter]) ) {
 191+ if ( $filter !== 'optional' && $filter !== 'ignored' ) {
 192+ throw new MWException( "No tagged messages for custom filter $filter" );
 193+ }
 194+ } else {
 195+ $taggedKeys = array_flip( $this->tags[$filter] );
 196+ $keys = $this->filterOnCondition( $keys, $taggedKeys, $condition );
 197+ }
193198 }
194199 $this->keys = $keys;
195200 }
Index: trunk/extensions/Translate/FFS.php
@@ -42,8 +42,10 @@
4343
4444 public function read( $code ) {
4545 $filename = $this->group->getSourceFilePath( $code );
46 - if ( $filename === null ) return array();
 46+ if ( $filename === null ) return false;
4747
 48+ if ( !file_exists($filename) ) return false;
 49+
4850 $input = file_get_contents( $filename );
4951 if ( $input === false ) throw new MWException( "Unable to read file $filename" );
5052
Index: trunk/extensions/Translate/Groups.php
@@ -167,7 +167,7 @@
168168 $ffs = $this->getFFS();
169169 if ( !$ffs ) throw new MWException( 'No FFS defined' );
170170 $data = $ffs->read( 'en' );
171 - return (bool) count($data['MESSAGES']);
 171+ return $data && count($data['MESSAGES']);
172172 }
173173
174174 public function load( $code ) {
@@ -179,7 +179,8 @@
180180 $ffs = $this->getFFS();
181181 if ( !$ffs ) throw new MWException( 'No FFS defined' );
182182 $data = $ffs->read( $code );
183 - return $data['MESSAGES'];
 183+
 184+ return $data ? $data['MESSAGES'] : array();
184185 }
185186 }
186187

Status & tagging log