r54824 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54823‎ | r54824 | r54825 >
Date:23:04, 11 August 2009
Author:conrad
Status:deferred
Tags:
Comment:
Handle case when map consists only of comments
Modified paths:
  • /trunk/extensions/Transliterator/Transliterator.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Transliterator/Transliterator.php
@@ -164,12 +164,12 @@
165165 $existing = $this->getExistingMapNames( $prefix );
166166
167167 if (! isset( $existing[$mappage] ) )
168 - $this->mMaps[$mappage] = false;
 168+ $map = false;
169169
170170 else
171 - $this->mMaps[$mappage] = $this->readMap( wfMsg( $mappage ), $mappage );
 171+ $map = $this->readMap( wfMsg( $mappage ), $mappage );
172172
173 - return $this->mMaps[$mappage];
 173+ return $this->mMaps[$mappage] = $map;
174174 }
175175
176176 /**
@@ -196,12 +196,22 @@
197197
198198 // Split lines and remove whitespace at beginning and end
199199 $lines = preg_split( "/(^|\s*\n)(\s*(#[^\n]*)?\n)*\s*/", $input."\n" );
200 - if ( $lines[0] == "" )
 200+
 201+ $count = count( $lines );
 202+
 203+ if ( $count > 0 && $lines[0] == "" ) {
201204 array_shift( $lines );
 205+ $count--;
 206+ }
202207
203 - if ( $lines[count( $lines ) - 1] == "" )
 208+ if ( $count > 0 && $lines[$count - 1] == "" ) {
204209 array_pop( $lines );
 210+ $count--;
 211+ }
205212
 213+ // The only content was comments
 214+ if ( $count == 0 )
 215+ return false;
206216
207217 // The first line can contain flags
208218 $first_line = $lines[0];

Status & tagging log