* (bug 1398) patch by Thue Janus Kristensen that modifies the behaviour of the
authorÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Sat, 26 Mar 2005 23:30:53 +0000 (23:30 +0000)
committerÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Sat, 26 Mar 2005 23:30:53 +0000 (23:30 +0000)
  'Go' button, if an IP address is entered the search engine first checks if an
  article by that name exists, otherwise it goes to the user contributions list
  of that search engine ( this would catch en.wp.org/wiki/127.0.0.1 ), also,
  entering a valid username with the current namespace-3 + : prefix will go to
  the users page, regardless of whether it contains any text or not.

includes/SearchEngine.php

index 2e83974..fc5dfc6 100644 (file)
@@ -74,11 +74,22 @@ class SearchEngine {
                        return $title;
                }
 
+               $title = Title::newFromText( $term );
+
                # Entering an IP address goes to the contributions page
-               if ( preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $term ) ) {
-                       $title = Title::makeTitle( NS_SPECIAL, "Contributions/" . $term );
-                       return $title;
+               if ( ( $title->getNameSpace() == NS_USER && User::isIP($title->getText() ) )
+                     || User::isIP( trim( $term ) ) ) {
+                       $t2 = Title::makeTitle( NS_SPECIAL, "Contributions/" . $title->getText() );
+                       return $t2;
                }
+
+
+               # Entering a user goes to the user page whether it's there or not
+               if ( $title->getNameSpace() == NS_USER ) {
+                        if (User::idFromName($title->getText())) {
+                                return $title;
+                        }
+                }
                
                return NULL;
        }