42 public function rescore( $search, $namespaces, $srchres, $limit ) {
44 $ns = in_array(
NS_MAIN, $namespaces ) ?
NS_MAIN : reset( $namespaces );
45 $t = Title::newFromText( $search, $ns );
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 );