42 public function rescore( $search, $namespaces, $srchres, $limit ) {
44 $ns = in_array(
NS_MAIN, $namespaces ) ?
NS_MAIN : reset( $namespaces );
46 if ( !
$t || !
$t->exists() ) {
50 $string =
$t->getPrefixedText();
51 $key = array_search( $string, $srchres );
52 if ( $key !==
false ) {
54 return $this->
pullFront( $key, $srchres );
57 if (
$t->isRedirect() ) {
59 $key = array_search( $target, $srchres );
60 if ( $key !==
false ) {
68 return $this->
pullFront( $key, $srchres );
71 if ( isset( $redirectTargetsToRedirect[$target] ) ) {
76 return $this->
pullFront( $redirectTargetsToRedirect[$target], $srchres );
80 if ( isset( $redirectTargetsToRedirect[$string] ) ) {
83 array_splice( $srchres, $redirectTargetsToRedirect[$string], 1 );
84 array_unshift( $srchres, $string );
90 array_unshift( $srchres, $string );
92 if ( count( $srchres ) > $limit ) {
93 array_pop( $srchres );
105 foreach ( $titles as $key => $titleText ) {
114 $result[$target] = $key;
126 $cut = array_splice( $array, $key, 1 );
127 array_unshift( $array, $cut[0] );
138 if ( !$page->exists() ) {
141 $redir = $page->getRedirectTarget();
142 return $redir ? $redir->getPrefixedText() :
null;