Consolidate Title normalization code in SearchUpdate
authoraude <aude.wiki@gmail.com>
Wed, 2 Dec 2015 15:42:18 +0000 (16:42 +0100)
committeraude <aude.wiki@gmail.com>
Wed, 2 Dec 2015 16:17:27 +0000 (17:17 +0100)
and rename the private method to be more clear

Change-Id: Iec7b934babddd102402cfa7616accd91fd3422ff

includes/deferred/SearchUpdate.php

index 867fc61..f6c80f4 100644 (file)
@@ -86,8 +86,7 @@ class SearchUpdate implements DeferrableUpdate {
                                continue;
                        }
 
-                       $indexTitle = $this->indexTitle( $search );
-                       $normalTitle = $search->normalizeText( $indexTitle );
+                       $normalTitle = $this->getNormalizedTitle( $search );
 
                        if ( $page === null ) {
                                $search->delete( $this->id, $normalTitle );
@@ -174,13 +173,13 @@ class SearchUpdate implements DeferrableUpdate {
        }
 
        /**
-        * Get a string representation of a title suitable for
+        * Get a normalized string representation of a title suitable for
         * including in a search index
         *
         * @param SearchEngine $search
         * @return string A stripped-down title string ready for the search index
         */
-       private function indexTitle( SearchEngine $search ) {
+       private function getNormalizedTitle( SearchEngine $search ) {
                global $wgContLang;
 
                $ns = $this->title->getNamespace();
@@ -200,6 +199,7 @@ class SearchUpdate implements DeferrableUpdate {
                if ( $ns == NS_FILE ) {
                        $t = preg_replace( "/ (png|gif|jpg|jpeg|ogg)$/", "", $t );
                }
-               return trim( $t );
+
+               return $search->normalizeText( trim( $t ) );
        }
 }