Index: trunk/phase3/includes/WatchlistEditor.php |
— | — | @@ -84,17 +84,21 @@ |
85 | 85 | * @return array |
86 | 86 | */ |
87 | 87 | private function extractTitles( $list ) { |
| 88 | + $titles = array(); |
88 | 89 | if( !is_array( $list ) ) { |
89 | | - $list = explode( "\n", $list ); |
| 90 | + $list = explode( "\n", trim( $list ) ); |
90 | 91 | if( !is_array( $list ) ) |
91 | 92 | return array(); |
92 | 93 | } |
93 | | - for( $i = 0; $i < count( $list ); $i++ ) { |
94 | | - $list[$i] = Title::newFromText( $list[$i] ); |
95 | | - if( !$list[$i] instanceof Title ) |
96 | | - unset( $list[$i] ); |
| 94 | + foreach( $list as $text ) { |
| 95 | + $text = trim( $text ); |
| 96 | + if( strlen( $text ) > 0 ) { |
| 97 | + $title = Title::newFromText( $text ); |
| 98 | + if( $title instanceof Title ) |
| 99 | + $titles[] = $title; |
| 100 | + } |
97 | 101 | } |
98 | | - return $list; |
| 102 | + return $titles; |
99 | 103 | } |
100 | 104 | |
101 | 105 | /** |