Last modified: 2014-02-18 11:31:37 UTC
Created attachment 13854 [details] patch for includes/specials/SpecialSearch.php In Mozilla Firefox you can create a "smart keyword" when you make a right-click to search field and select "Add a Keyword for this Search...". Then you can create a new bookmark with an keyword. https://support.mozilla.org/en-US/kb/how-search-from-address-bar When you do this for enwiki you create a bookmark to the URL https://en.wikipedia.org/w/index.php?search=%s&title=Special%3ASearch With the keyword "wp" you can enter "wp foo" then the "%s" gets substituted by "foo" and the URL https://en.wikipedia.org/w/index.php?search=foo&title=Special%3ASearch gets loaded. The search redirects (302) to https://en.wikipedia.org/wiki/Foo and shows the article [[Foobar]] because [[Foo]] is a redirect to [[Foobar]]. When you open the keyword without an search string "wp" the Firefox opens the URL https://en.wikipedia.org/w/index.php?search=&title=Special%3ASearch which is a empty search page. But when you open this bookmark as normal bookmark then the Firefox opens the URL https://en.wikipedia.org/w/index.php?search=%s&title=Special%3ASearch and opens the article [[%s]]. When [[%s]] doesn't exist a search result page for search string "%s" is shown. On many projects there exist a redirect from [[%s]] to the Main Page of the project so these users gets redirected to a useful page. But this redirect is workaround. This workaround has also the disadvantage that the Main Page is shown on a strange URL. I suggest to create a workaround in MediaWiki to catch this request: When [[%s]] is not existent then ?search=%s&title=Special%3ASearch redirects to the Main Page. When [[%s]] is not existent then ?search=%s&title=Special%3ASearch&fulltext=Search shows a search result page to the search string "%s" When [[%s]] exists then ?search=%s&title=Special%3ASearch redirects to this articel [[%s]] When [[%s]] exists then ?search=%s&title=Special%3ASearch&fulltext=Search shows a search result page to the search string "%s" I created a patch with this behavior.
Hi Fomafix, thanks for your patch! You probably know, but you are welcome to use Developer access https://www.mediawiki.org/wiki/Developer_access to submit this as a Git branch directly into Gerrit: https://www.mediawiki.org/wiki/Git/Tutorial
I'm sorry, but I don't support this. See our discussion in the German Wikipedia.[1] The patch introduces a hard coded redirect for an - in my opinion - way to specific case. What if an user enters "wp %s" because he wants to search for "%s". With the proposed patch he will be redirected to the main page. What if an other user agent does not use "%s" but "{0}" or "$0" or something like that instead? Do we have to add this too? My suggestion is to fix bug 48028. All redirects should do real 301 redirects. This will also fix other problems like not being able to copy & paste the real URL of an article when it's called via a redirect. This way we can keep the redirect [[%s]] without confusing visitors with a strange "%25s" in the URL. [1]http://de.wikipedia.org/wiki/Wikipedia:Löschkandidaten/19._November_2013#.25s_.28Weiterleitung_auf_die_Hauptseite.29
[[Talk:%s]] has the history of this Firefox quirk, I think.