From: Ævar Arnfjörð Bjarmason Date: Sat, 26 Mar 2005 23:30:53 +0000 (+0000) Subject: * (bug 1398) patch by Thue Janus Kristensen that modifies the behaviour of the X-Git-Tag: 1.5.0alpha1~497 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=435ed6274eb2d7daf8681c3a16ab6883541c59a5;p=lhc%2Fweb%2Fwiklou.git * (bug 1398) patch by Thue Janus Kristensen that modifies the behaviour of the '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. --- diff --git a/includes/SearchEngine.php b/includes/SearchEngine.php index 2e83974c8f..fc5dfc629b 100644 --- a/includes/SearchEngine.php +++ b/includes/SearchEngine.php @@ -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; }