From 435ed6274eb2d7daf8681c3a16ab6883541c59a5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sat, 26 Mar 2005 23:30:53 +0000 Subject: [PATCH] * (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. --- includes/SearchEngine.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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; } -- 2.20.1