From 33c897f16f3caf247d0c6ddd7618b4e168cfee54 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Wed, 4 Jul 2007 10:18:10 +0000 Subject: [PATCH] Make WatchlistEditor::extractTitles() more robust when dealing with blank lines --- includes/WatchlistEditor.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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; } /** -- 2.20.1