Merge "(Bug 23472) Removed undesirable space after external link url in printout"
[lhc/web/wiklou.git] / includes / search / SearchUpdate.php
index 40dd36c..35199d6 100644 (file)
@@ -34,7 +34,12 @@ class SearchUpdate implements DeferrableUpdate {
        private $mTitleWords;
 
        function __construct( $id, $title, $text = false ) {
-               $nt = Title::newFromText( $title );
+               if ( is_string( $title ) ) {
+                       $nt = Title::newFromText( $title );
+               } else {
+                       $nt = $title;
+               }
+
                if( $nt ) {
                        $this->mId = $id;
                        $this->mText = $text;
@@ -61,7 +66,7 @@ class SearchUpdate implements DeferrableUpdate {
                $lc = SearchEngine::legalSearchChars() . '&#;';
 
                if( $this->mText === false ) {
-                       $search->updateTitle($this->mId,
+                       $search->updateTitle( $this->mId,
                                $search->normalizeText( Title::indexTitle( $this->mNamespace, $this->mTitle ) ) );
                        wfProfileOut( __METHOD__ );
                        return;
@@ -74,7 +79,7 @@ class SearchUpdate implements DeferrableUpdate {
                $text = preg_replace( "/<\\/?\\s*[A-Za-z][^>]*?>/",
                        ' ', $wgContLang->lc( " " . $text . " " ) ); # Strip HTML markup
                $text = preg_replace( "/(^|\\n)==\\s*([^\\n]+)\\s*==(\\s)/sD",
-                 "\\1\\2 \\2 \\2\\3", $text ); # Emphasize headings
+                       "\\1\\2 \\2 \\2\\3", $text ); # Emphasize headings
 
                # Strip external URLs
                $uc = "A-Za-z0-9_\\/:.,~%\\-+&;#?!=()@\\x80-\\xFF";
@@ -92,7 +97,7 @@ class SearchUpdate implements DeferrableUpdate {
                $text = preg_replace( $pat2, " \\1 \\3", $text );
 
                $text = preg_replace( "/([^{$lc}])([{$lc}]+)]]([a-z]+)/",
-                 "\\1\\2 \\2\\3", $text ); # Handle [[game]]s
+                       "\\1\\2 \\2\\3", $text ); # Handle [[game]]s
 
                # Strip all remaining non-search characters
                $text = preg_replace( "/[^{$lc}]+/", " ", $text );
@@ -122,7 +127,7 @@ class SearchUpdate implements DeferrableUpdate {
                wfRunHooks( 'SearchUpdate', array( $this->mId, $this->mNamespace, $this->mTitle, &$text ) );
 
                # Perform the actual update
-               $search->update($this->mId, $search->normalizeText( Title::indexTitle( $this->mNamespace, $this->mTitle ) ),
+               $search->update( $this->mId, $search->normalizeText( Title::indexTitle( $this->mNamespace, $this->mTitle ) ),
                                $search->normalizeText( $text ) );
 
                wfProfileOut( __METHOD__ );