In an extension, I'd like to detect when the "Go" button has been used to jump directly to an article that exists. Any ideas how to do this? Here is what I have tried so far:
- The Special:Search page (file specials/SpecialSearch.php) does an immediate redirect to the target, with no hook provided. - There is a hook SpecialSearchNogomatch that detects the use of the "Go" button but only when the target doesn't exist. That's the opposite of what I need: in my case, the target does exist. This hook is called too late anyway (after the redirect). - The hooks SpecialSearchResults and SpecialSearchNoResults do not fire in this situation - Maybe use a hook in the Title or Article class, but how to detect only the Go button? I don't want to include articles that have been visited by URL or by clicking a wiki link.
By brute force, I could probably make my extension run on every page load (ugh), tracking if I'm on Special:Search with a query string parameter "Go=go", and then use the SpecialSearchNogomatch hook to exclude searches that fail. But that feels like an inefficient hack.
Thanks for any ideas.... DanB
I wrote:
In an extension, I'd like to detect when the "Go" button has been used to jump directly to an article that exists. Any ideas how to do this?
Nobody responded, so just to follow up for posterity...
I ended up adding a hook in specials/SpecialSearch.php. It needed to be added to both classes SpecialSearch and SpecialSearchOld. A core code change is not ideal, but I couldn't see any other way to accomplish the task.
DanB
Hi Daniel,
In an extension, I'd like to detect when the "Go" button has been used to jump directly to an article that exists. Any ideas how to do this?
I used the Firefox add-on Live HTTP Headers for a peak under the hood (https://addons.mozilla.org/de/firefox/addon/3829).
This is the header sent with the "Go" button:
GET /mediawiki/index.php?title=Spezial%3ASearch&search=keyword&go=Seite HTTP/1.1
and this using "Search":
GET /mediawiki/index.php?title=Spezial%3ASearch&search=keyword&fulltext=Suchen HTTP/1.1
You might be able to incept this header information somehow.
hth Frank
mediawiki-l@lists.wikimedia.org