44 public function rescore( $search, $namespaces, $srchres, $limit ) {
46 $ns = in_array(
NS_MAIN, $namespaces ) ?
NS_MAIN : reset( $namespaces );
47 $t = Title::newFromText( $search, $ns );
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() ) {
60 $target = $this->getRedirectTarget(
$t );
61 $key = array_search( $target, $srchres );
62 if ( $key !==
false ) {
70 return $this->pullFront( $key, $srchres );
72 $redirectTargetsToRedirect = $this->redirectTargetsToRedirect( $srchres );
73 if ( isset( $redirectTargetsToRedirect[$target] ) ) {
78 return $this->pullFront( $redirectTargetsToRedirect[$target], $srchres );
81 $redirectTargetsToRedirect = $this->redirectTargetsToRedirect( $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 );