From: Chad Horohoe Date: Wed, 16 Apr 2014 00:20:15 +0000 (-0700) Subject: Get rid of Title::indexTitle and Title::getIndexTitle() X-Git-Tag: 1.31.0-rc.0~16196^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=d6c4ab939024ec07bb679be664089e5584a6bb26;p=lhc%2Fweb%2Fwiklou.git Get rid of Title::indexTitle and Title::getIndexTitle() Nothing used them other than SearchUpdate, nor should they. Move implementation there and make it private. Change-Id: Iafc6f6d59487bd8c53cb99b2147815b2d70ead83 --- diff --git a/includes/FakeTitle.php b/includes/FakeTitle.php index 4aa15bfdf7..2f4d26b92b 100644 --- a/includes/FakeTitle.php +++ b/includes/FakeTitle.php @@ -42,7 +42,6 @@ class FakeTitle extends Title { function hasFragment() { $this->error(); } function getFragmentForURL() { $this->error(); } function getDefaultNamespace() { $this->error(); } - function getIndexTitle() { $this->error(); } function getPrefixedDBkey() { $this->error(); } function getPrefixedText() { $this->error(); } function getFullText() { $this->error(); } diff --git a/includes/Title.php b/includes/Title.php index 31e586835e..9d08a63cbc 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -662,34 +662,6 @@ class Title { return $out; } - /** - * Get a string representation of a title suitable for - * including in a search index - * - * @param int $ns a namespace index - * @param string $title text-form main part - * @return String a stripped-down title string ready for the search index - */ - public static function indexTitle( $ns, $title ) { - global $wgContLang; - - $lc = SearchEngine::legalSearchChars() . '&#;'; - $t = $wgContLang->normalizeForSearch( $title ); - $t = preg_replace( "/[^{$lc}]+/", ' ', $t ); - $t = $wgContLang->lc( $t ); - - # Handle 's, s' - $t = preg_replace( "/([{$lc}]+)'s( |$)/", "\\1 \\1's ", $t ); - $t = preg_replace( "/([{$lc}]+)s'( |$)/", "\\1s ", $t ); - - $t = preg_replace( "/\\s+/", ' ', $t ); - - if ( $ns == NS_FILE ) { - $t = preg_replace( "/ (png|gif|jpg|jpeg|ogg)$/", "", $t ); - } - return trim( $t ); - } - /** * Make a prefixed DB key from a DB key and a namespace index * @@ -1271,16 +1243,6 @@ class Title { return $this->mDefaultNamespace; } - /** - * Get title for search index - * - * @return String a stripped-down title string ready for the - * search index - */ - public function getIndexTitle() { - return Title::indexTitle( $this->mNamespace, $this->mTextform ); - } - /** * Get the Title fragment (i.e.\ the bit after the #) in text form * diff --git a/includes/deferred/SearchUpdate.php b/includes/deferred/SearchUpdate.php index 7ca4158a44..06df440166 100644 --- a/includes/deferred/SearchUpdate.php +++ b/includes/deferred/SearchUpdate.php @@ -81,7 +81,7 @@ class SearchUpdate implements DeferrableUpdate { wfProfileIn( __METHOD__ ); $page = WikiPage::newFromId( $this->id, WikiPage::READ_LATEST ); - $indexTitle = Title::indexTitle( $this->title->getNamespace(), $this->title->getText() ); + $indexTitle = $this->indexTitle(); foreach ( SearchEngine::getSearchTypes() as $type ) { $search = SearchEngine::create( $type ); @@ -174,4 +174,33 @@ class SearchUpdate implements DeferrableUpdate { return $text; } + + /** + * Get a string representation of a title suitable for + * including in a search index + * + * @return String a stripped-down title string ready for the search index + */ + private function indexTitle() { + global $wgContLang; + + $ns = $this->title->getNamespace(); + $title = $this->title->getText(); + + $lc = SearchEngine::legalSearchChars() . '&#;'; + $t = $wgContLang->normalizeForSearch( $title ); + $t = preg_replace( "/[^{$lc}]+/", ' ', $t ); + $t = $wgContLang->lc( $t ); + + # Handle 's, s' + $t = preg_replace( "/([{$lc}]+)'s( |$)/", "\\1 \\1's ", $t ); + $t = preg_replace( "/([{$lc}]+)s'( |$)/", "\\1s ", $t ); + + $t = preg_replace( "/\\s+/", ' ', $t ); + + if ( $ns == NS_FILE ) { + $t = preg_replace( "/ (png|gif|jpg|jpeg|ogg)$/", "", $t ); + } + return trim( $t ); + } }