Last modified: 2010-05-15 15:33:53 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T3398, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 1398 - Using go button to go to empty userpage for existing user goes to search screen
Using go button to go to empty userpage for existing user goes to search screen
Product: MediaWiki
Classification: Unclassified
Search (Other open bugs)
All All
: Normal normal with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-reviewed
Depends on:
  Show dependency treegraph
Reported: 2005-01-24 12:16 UTC by Thue Janus Kristensen
Modified: 2010-05-15 15:33 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---

Patch to fix "go"-ing to a blank userpage (1.45 KB, patch)
2005-01-24 12:17 UTC, Thue Janus Kristensen
Fix issues raised by Brion Vibber (2.24 KB, patch)
2005-02-03 17:04 UTC, Thue Janus Kristensen
Implement comments (1.11 KB, patch)
2005-02-03 21:34 UTC, Thue Janus Kristensen

Description Thue Janus Kristensen 2005-01-24 12:16:21 UTC
Sometimes I will type fx "User:Thue" into the search/go box on the left hand
side, and in that case when I press the "go" button I expect to be taken to that
users userpage, whether it is blank or not. Especially I don't want to be taken
to the search screen if the user exists, which mediawiki currently does if the
userpage is blank.

Attached (hopefully...) is a patch that fixes this. It also fixes
-recognize IP numbers as "User:" instead of just "".
-recognize IP adresses and usernames even if they contain leading blankspace
Comment 1 Thue Janus Kristensen 2005-01-24 12:17:41 UTC
Created attachment 217 [details]
Patch to fix "go"-ing to a blank userpage
Comment 2 Antoine "hashar" Musso (WMF) 2005-02-01 02:32:06 UTC
Commited to REL1_4 and HEAD and will be available in beta6.
Thanks for the patch !
Comment 3 Brion Vibber 2005-02-01 07:51:33 UTC
I've reverted the patch for the moment as there are a number of problems with it.

* It hard-codes the English string "user", and doesn't allow localized user namespaces.

* Title::makeTitle doesn't perform validity checks as it's meant mainly for data pulled from the database which has been 
previously screened. Use Title::makeTitleSafe().

* The ereg_replace is a bit odd. Trimming of stray whitespace from the search term should be done at the top end in 
SpecialSearch.php, not down there.
Comment 4 Thue Janus Kristensen 2005-02-03 17:04:25 UTC
Created attachment 255 [details]
Fix issues raised by Brion Vibber

*User namespace name internationalized.

*Actually I didn't insert the Title::makeTitle call; it was already there, but
this patch fixes it. It is guarded by a regexp comparison that ensured it could
only be an IP address, so it was probably safe anyway.

*Moved removal of leading blankspace all the way up to top of searchengine.php.
I looked down in the search code if there were any case where that might be a
problem because leading blankspace was really part of the search term, but that
doesn't seem to be the case. (it wouldn't make much sense either as far as I
can see)
Comment 5 Thue Janus Kristensen 2005-02-03 17:09:57 UTC
Comment on attachment 255 [details]
Fix issues raised by Brion Vibber

diff -ur /home/thue/mediawiki/mediawiki-1.4beta5/includes/SearchEngine.php
--- /home/thue/mediawiki/mediawiki-1.4beta5/includes/SearchEngine.php  
2004-12-26 06:03:48.000000000 +0100
+++ wiki/includes/SearchEngine.php	2005-02-03 17:35:57.000000000 +0100
@@ -45,6 +45,8 @@
	 * @access private
	function getNearMatch( $term ) {
+		global $wgContLang;
		# Exact match? No need to look further.
		$title = Title::newFromText( $term );
		if (is_null($title))
@@ -75,11 +77,21 @@
			return $title;

		# 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 );
+		$userprefixtext = $wgContLang->getNsText( NS_USER);
+		if ( preg_match(
"/^(${userprefixtext}:)?".'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/i', $term ) ) {
+			$title = Title::makeTitleSafe( NS_SPECIAL,
"Contributions/" . $term );
			return $title;
+		# Entering a user goes to the user page whether it's there or
+		if ( preg_match( "/^${userprefixtext}:/i", $term ) ) {
+			 if (User::idFromName($term)) {
+			  $title = Title::newFromURL( $term );
+			  return $title;
+			 }
+		}

		return NULL;
diff -ur /home/thue/mediawiki/mediawiki-1.4beta5/includes/SpecialSearch.php
--- /home/thue/mediawiki/mediawiki-1.4beta5/includes/SpecialSearch.php 
2005-01-07 04:17:26.000000000 +0100
+++ wiki/includes/SpecialSearch.php	2005-02-03 17:47:04.000000000 +0100
@@ -29,6 +29,7 @@
	global $wgRequest, $wgUser;

	$search = $wgRequest->getText( 'search', $par );
+	$search = ereg_replace('[[:blank:]]*', '', $search);
	$searchPage = new SpecialSearch( $wgRequest, $wgUser );
	if( $wgRequest->getVal( 'fulltext' ) ||
		!is_null( $wgRequest->getVal( 'offset' ) ) ||
Comment 6 Brion Vibber 2005-02-03 19:50:24 UTC
Please don't paste the code into the comment field; it clutters up the page.

As I understand it, this new code will accept _only_ the canonical localized form of the namespace. The 
standard English names are always accepted in titles as alternates, and some languages may provide 
alternates for some namespaces as well (for instance, with or without accept marks). It would be better to 
simply make a title object and check if its namespace is NS_USER; this will allow the standard namespace 
parsing code to do its thing.

As for the whitespace trimming; I would simply use the trim() function rather than the ereg_replace.
Comment 7 Thue Janus Kristensen 2005-02-03 21:34:28 UTC
Created attachment 256 [details]
Implement comments

Ok - now I am using all the right functions that already existed elsewhere. I
even tidied up the preexisting code by finding User::isIP().

I changed it back to using makeTitle() instead of makeTitleSafe() as I am now
using Title->getText() as input, which I assume is safe enough.

I did not mean to paste the previous patch into bugzilla - I had made an error
in the attached patch, and thought I could edit it in place, but bugzilla
surpriced me by creating it as a new comment.
Comment 8 Ævar Arnfjörð Bjarmason 2005-03-26 23:30:51 UTC
Applied to HEAD and REL1_4, thanks for the patch.

Note You need to log in before you can comment on or make changes to this bug.