Last modified: 2014-10-12 13:17:58 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 T26214, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 24214 - mediawiki.searchSuggest: Support user search namespace preferences
mediawiki.searchSuggest: Support user search namespace preferences
Status: PATCH_TO_REVIEW
Product: MediaWiki
Classification: Unclassified
Interface (Other open bugs)
1.23.0
All All
: Normal normal (vote)
: Future release
Assigned To: Nobody - You can work on this!
:
Depends on: 30323
Blocks: 27411 71976
  Show dependency treegraph
 
Reported: 2010-07-01 17:54 UTC by Robert Stojnic
Modified: 2014-10-12 13:17 UTC (History)
12 users (show)

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


Attachments

Description Robert Stojnic 2010-07-01 17:54:08 UTC
SimpleSearch searches only in the main namespace (namespaces=0) and ignores user/site-configured default search namespaces, as well as checked namespaces in advanced search. 

This works with mwsuggest.js and is implemented in function os_getNamespaces()

Raised on en.wp VPT:
http://en.wikipedia.org/wiki/WP:VPT#Search_bar
Comment 1 Liangent 2010-07-01 18:02:09 UTC
Also reported on [[zh:WP:UX]], and the reporter says prefixing the namespace names works for a specific namespace.
Comment 2 Waihorace 2010-07-07 12:21:03 UTC
I also have the same idea.
Comment 3 Thehelpfulone 2012-06-22 19:45:20 UTC
Reassign to default per bug 37789
Comment 4 Krinkle 2012-09-23 00:06:45 UTC
Is this still happening? It has since been extracted into a stand-alone extension (Extension:Vector).
Comment 5 Krinkle 2012-11-06 21:27:41 UTC
Moving to mediawiki-core/interface and setting to unconfirmed as it has been changed quite a bit since 2010.
Comment 6 Chuck Aksamit 2013-11-18 19:50:41 UTC
Confirmed still broken in 1.22.0rc2
Comment 7 Andre Klapper 2013-11-19 09:11:20 UTC
Thanks for retesting!
Comment 8 Chuck Aksamit 2013-11-19 11:01:29 UTC
Here's a fix since the data is right there in mw.user.options.

Add this function to mediawiki.searchSuggest.js:

		// Get current namespaces
		function getNamespaces() {
			var state = null,
				namespaces = '',
				i = 0,
				limit = 1000;
			do {
				state = mw.user.options.get('searchNs'+i);
				switch (state) {
					case true:
						namespaces += i+'|';
					case null:
						break;
				}
				i++;
			} while (state != null);
			if (namespaces.length > 1) {
				namespaces = namespaces.substring(0, namespaces.length-1);
			}
			return namespaces;
		}

Then, on line 149, change "namespace: 0," to "namespace: getNamespaces(),".

Code I am referencing: https://git.wikimedia.org/blob/mediawiki%2Fcore.git/8bb12babcd4c791c50aa53f14f68224162aaef80/resources%2Fmediawiki%2Fmediawiki.searchSuggest.js
Comment 9 Chuck Aksamit 2013-11-19 11:25:00 UTC
One adjustment on the return so it always at least sends 0:

		// Get current namespaces
		function getNamespaces() {
			var state = null,
				namespaces = '',
				i = 0,
				limit = 1000;
			do {
				state = mw.user.options.get('searchNs'+i);
				switch (state) {
					case true:
						namespaces += i+'|';
					case null:
						break;
				}
				i++;
			} while (state != null);
			if (namespaces.length > 1) {
				return namespaces.substring(0, namespaces.length-1);
			}
			return 0;
		}
Comment 10 Chuck Aksamit 2013-11-19 12:12:23 UTC
I didn't realize how custom namespaces work so the above code wont work. Something like this should though:

// Get current namespaces
		function getNamespaces() {
			var namespaces = '',
				options = mw.user.options.get();
			for(var opt in options) {
				if(opt.substring(0,8) === 'searchNs') {
					if(options[opt] === true) {
						namespaces += opt.substr(8)+'|';
					}
				}
			}
			if (namespaces.length > 1) {
				return namespaces.substring(0, namespaces.length-1);
			}
			else {
				return 0;
			}
		}
Comment 11 Andre Klapper 2013-11-19 12:17:21 UTC
Oh yay, thanks for going through the code! 
You are very 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
Putting your branch in Git makes it easier to review it quickly.
Thanks again!
Comment 12 Subfader 2014-10-05 22:19:42 UTC
Somebody please add this to core. I was about to open a request for that.
Comment 13 Gerrit Notification Bot 2014-10-06 02:03:43 UTC
Change 164893 had a related patch set uploaded by saper:
searchSuggest.js: Pass user ns preferences to API

https://gerrit.wikimedia.org/r/164893

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


Navigation
Links