44 public function rescore( $search, $namespaces, $srchres, $limit ) {
46 $ns = in_array(
NS_MAIN, $namespaces ) ?
NS_MAIN : reset( $namespaces );
48 if ( !
$t || !
$t->exists() ) {
52 $string =
$t->getPrefixedText();
53 $key = array_search( $string, $srchres );
54 if ( $key !==
false ) {
56 return $this->
pullFront( $key, $srchres );
59 if (
$t->isRedirect() ) {
61 $key = array_search( $target, $srchres );
62 if ( $key !==
false ) {
70 return $this->
pullFront( $key, $srchres );
73 if ( isset( $redirectTargetsToRedirect[$target] ) ) {
78 return $this->
pullFront( $redirectTargetsToRedirect[$target], $srchres );
82 if ( isset( $redirectTargetsToRedirect[$string] ) ) {
85 array_splice( $srchres, $redirectTargetsToRedirect[$string], 1 );
86 array_unshift( $srchres, $string );
92 array_unshift( $srchres, $string );
94 if ( count( $srchres ) > $limit ) {
95 array_pop( $srchres );
107 foreach ( $titles as $key => $titleText ) {
116 $result[$target] = $key;
129 $cut = array_splice( $array, $key, 1 );
130 array_unshift( $array, $cut[0] );
140 $page = MediaWikiServices::getInstance()->getWikiPageFactory()->newFromTitle(
$title );
141 if ( !$page->exists() ) {
144 $redir = $page->getRedirectTarget();
145 return $redir ? $redir->getPrefixedText() :
null;