From: Rob Church Date: Wed, 4 Jul 2007 10:18:10 +0000 (+0000) Subject: Make WatchlistEditor::extractTitles() more robust when dealing with blank lines X-Git-Tag: 1.31.0-rc.0~52278 X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=commitdiff_plain;h=33c897f16f3caf247d0c6ddd7618b4e168cfee54;p=lhc%2Fweb%2Fwiklou.git Make WatchlistEditor::extractTitles() more robust when dealing with blank lines --- diff --git a/includes/WatchlistEditor.php b/includes/WatchlistEditor.php index a8974c0750..915e7f25c5 100644 --- a/includes/WatchlistEditor.php +++ b/includes/WatchlistEditor.php @@ -84,17 +84,21 @@ class WatchlistEditor { * @return array */ private function extractTitles( $list ) { + $titles = array(); if( !is_array( $list ) ) { - $list = explode( "\n", $list ); + $list = explode( "\n", trim( $list ) ); if( !is_array( $list ) ) return array(); } - for( $i = 0; $i < count( $list ); $i++ ) { - $list[$i] = Title::newFromText( $list[$i] ); - if( !$list[$i] instanceof Title ) - unset( $list[$i] ); + foreach( $list as $text ) { + $text = trim( $text ); + if( strlen( $text ) > 0 ) { + $title = Title::newFromText( $text ); + if( $title instanceof Title ) + $titles[] = $title; + } } - return $list; + return $titles; } /**