Last modified: 2014-11-20 22:50:02 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 T60467, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 58467 - Wrong smart keyword on Wikidata
Wrong smart keyword on Wikidata
Status: PATCH_TO_REVIEW
Product: MediaWiki extensions
Classification: Unclassified
WikidataClient (Other open bugs)
master
All All
: Low minor (vote)
: ---
Assigned To: Wikidata bugs
u=dev c=frontend p=0
: javascript, need-volunteer
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-12-13 22:03 UTC by Fomafix
Modified: 2014-11-20 22:50 UTC (History)
7 users (show)

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


Attachments

Description Fomafix 2013-12-13 22:03:44 UTC
Firefox generates smart keywords from a search bar: https://support.mozilla.org/en-US/kb/how-search-from-address-bar

On Wikidata it generates the wrong bookmark
https://www.wikidata.org/w/index.php?=%s&search=&title=Special%3ASearch

Expected bookmark is
https://www.wikidata.org/w/index.php?search=%s&title=Special%3ASearch

The reason is in the JavaScript code. The original HTML from server is

<form action="/w/index.php" id="searchform">
	<div id="simpleSearch">
		<input name="search" placeholder="Search" title="Search Wikidata [f]" accesskey="f" id="searchInput" />
		<button type="submit" name="button" title="Search the pages for this text" id="searchButton">
			<img src="//bits.wikimedia.org/static-1.23wmf6/skins/vector/images/search-ltr.png?303-4" alt="Search" width="12" height="13" />
		</button>
		<input type='hidden' name="title" value="Special:Search"/>
	</div>
</form>

JavaScript converts this the following HTML code with a duplicate <input> element:

<form id="searchform" action="/w/index.php">
	<div id="simpleSearch">
		<input id="searchInput" accesskey="f" title="Search Wikidata [alt-shift-f]" placeholder="Search" class="ui-autocomplete-input ui-suggester-input ui-entityselector-input" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true" tabindex="1">
		<input type="hidden" name="search" value="">
		<button id="searchButton" title="Search the pages for this text" name="button" type="submit">
			<img width="12" height="13" alt="Search" src="//bits.wikimedia.org/static-1.23wmf6/skins/vector/images/search-ltr.png?303-4">
		</button>
		<input type="hidden" value="Special:Search" name="title">
	</div>
</form>

The JavaScript code on www.mediawiki.org works and converts the HTML to

<form id="searchform" action="/w/index.php">
	<div id="improvedsearch-toggle" class="vectorMenu" title="Wikimedia tech" style="width: 20px; height: 1.3em; margin-left: 14.5em; margin-right: -0.8em;"></div>
	<div id="simpleSearch">
		<input id="searchInput" accesskey="f" title="Search MediaWiki [alt-shift-f]" placeholder="Search" name="search" tabindex="1" autocomplete="off">
		<button id="searchButton" title="Search the pages for this text" name="button" type="submit">
			<img width="12" height="13" alt="Search" src="//bits.wikimedia.org/static-1.23wmf7/skins/vector/images/search-ltr.png?303-4">
		</button>
		<input type="hidden" value="Special:Search" name="title">
	</div>
</form>
Comment 1 Thiemo Mättig 2014-11-19 10:43:19 UTC
Oh, wow. This is clearly a bug in Firefox. You know that, right? Not that we shouldn't work around it. We should.

I had two ideas:

1.) Switch the order of the two <input>, the named hidden <input> first, our unnamed <input> after.
Result: .../index.php?search=&=%s&title=Spezial%3ASuche

2.) Give both <input> the same name="search".
Result: .../index.php?search=%s&search=&title=Spezial%3ASuche
Dang, this overrides the user's input with an empty string.

3.) Do both. Works.
Comment 2 Gerrit Notification Bot 2014-11-19 10:44:29 UTC
Change 174387 had a related patch set uploaded by Thiemo Mättig (WMDE):
Fix entitysearch to support Firefox smart keyword

https://gerrit.wikimedia.org/r/174387
Comment 3 Fomafix 2014-11-20 10:41:09 UTC
There is not bug in Firefox. It converts the <input>s in the form to a query string like in HTML. The reason are the two <input>s. Why are there two <input>s? They seams to be redundant. The implementation on mediawiki.org works with one <input>.
Comment 4 Thiemo Mättig 2014-11-20 12:45:08 UTC
Turning an unnamed input into index.php?=%s is clearly a bug in Firefox. I'm not aware of a server side language that supports unnames GET variables. In PHP that would be $_GET['']. I just tried that just to be sure and no, PHP doesn't support this.

Again, this doesn't mean we should not work around this issue. See my patch.
Comment 5 Fomafix 2014-11-20 22:50:02 UTC
Ok, an <input> without name is ignored in the normal transformation from a <form> to a query string. Here has the <input> for which the smart keyword is requested no name. When this <input> get omitted the query string for the smart keyword would have no %s. ?=%s is a comprehensible query string for the smart keyword on a <input> without a name.

Generating two <input>s with the same name is a bad solution for this problem. The right solution is to combine the two <input>s to one <input>.

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


Navigation
Links