Index: trunk/extensions/Transliterator/Transliterator.php |
— | — | @@ -164,12 +164,12 @@ |
165 | 165 | $existing = $this->getExistingMapNames( $prefix ); |
166 | 166 | |
167 | 167 | if (! isset( $existing[$mappage] ) ) |
168 | | - $this->mMaps[$mappage] = false; |
| 168 | + $map = false; |
169 | 169 | |
170 | 170 | else |
171 | | - $this->mMaps[$mappage] = $this->readMap( wfMsg( $mappage ), $mappage ); |
| 171 | + $map = $this->readMap( wfMsg( $mappage ), $mappage ); |
172 | 172 | |
173 | | - return $this->mMaps[$mappage]; |
| 173 | + return $this->mMaps[$mappage] = $map; |
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
— | — | @@ -196,12 +196,22 @@ |
197 | 197 | |
198 | 198 | // Split lines and remove whitespace at beginning and end |
199 | 199 | $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] == "" ) { |
201 | 204 | array_shift( $lines ); |
| 205 | + $count--; |
| 206 | + } |
202 | 207 | |
203 | | - if ( $lines[count( $lines ) - 1] == "" ) |
| 208 | + if ( $count > 0 && $lines[$count - 1] == "" ) { |
204 | 209 | array_pop( $lines ); |
| 210 | + $count--; |
| 211 | + } |
205 | 212 | |
| 213 | + // The only content was comments |
| 214 | + if ( $count == 0 ) |
| 215 | + return false; |
206 | 216 | |
207 | 217 | // The first line can contain flags |
208 | 218 | $first_line = $lines[0]; |