Page MenuHomePhabricator

Limiting which namespaces can be searched
Open, LowPublicFeature

Description

As suggested on the talk page in the URL field. Could be set with a variable, $wgSearchOnlyContentNamespaces, which would default to false, of course.

On the other hand, the default doesn't count Project: as a content namespace, and people might want to search it without changing that, so maybe it would make more sense not to couple this with $wgContentNamespaces, and instead make it as flexible as possible with a new variable, $wgSearchableNamespaces, which would default to including all namespaces. This might not work too well with extra namespaces, though, so maybe it would be better to have $wgUnsearchableNamespaces.


Version: 1.16.x
Severity: minor
URL: http://www.mediawiki.org/w/index.php?title=Manual_talk:%24wgContentNamespaces&oldid=203869#Namespaces_without_real_content_in_search

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 10:17 PM
bzimport added a project: MediaWiki-Search.
bzimport set Reference to bz15018.
bzimport added a subscriber: Unknown Object (MLST).

Basically, as I understand it, we have $wgContentNamespaces which define the namespaces that count as content (for stats) and $wgNamespacesToBeSearchedDefault which defines which namespaces are selected for searching in a new user's preferences. This request is asking for a way of suppressing namespaces from this list, and from the list of namespaces at the bottom of the search results page (the 'advanced search' feature).

There are several options. The two suggested above are:

  • $wgSearchableNamespaces - to hold an array of namespaces that appear in these lists (though you have to remember to update this if new namespaces are added)
  • $wgNonSearchableNamespaces - to hold an array of namespaces to omit from the list.

An alternative and simpler (UI-wise) solution might be to have an replacement interface that can be enabled via LocalSettings.php:

  • $wgSearchUseSimplifiedNamespaces - if false, behaviour is same as now. If true, the list of namespaces in the advanced search and the user preferences is replaced with 3 radio buttons to toggle between 'search main content namespaces' (only those defined in $wgContentNamespaces) ''search all content namespaces' (everything except Image:, MediaWiki:, Template: and Category:) and 'search entire wiki' which includes the lot. There should also be an 'include talk pages' option which if selected searches the talk pages of the selected namespaces.

daniel.remeseiro wrote:

i think .... also there are many people who wants to enable/disable the advanced search.
I suggest a new global boolean var:

$wgPowerSearchSelection - if false nothing happens , the advanced search shows as mediawiki now: all checkboxes of all namespaces.

-if true then triggers to read the $wgNamespacesToBeSearchedDefault array values and show just this checkboxes options.

Offline, I discovered the same bug, and wrote the following:

Search namespaces hardwired

Below I'm not talking about which namespaces the user can have checked
by default, but instead what namespaces he will see visible at all on
Special:Search and Special:Preferences in the first place.

SearchEngine.php's searchableNamespaces() is hardwired and
doesn't let anybody e.g., take NS_FILE, NS_FILE_TALK off the list, for
sites with $wgEnableUploads = false; meaning they show up in
Special:Search, though useless.
What's worse is in Preferences.php, the namespaces are again hardwired:

foreach( $wgContLang->getNamespaces() as $ns => $name ) {
  if ($ns < 0) continue;

Sure, searchableNamespaces() is seen in several places in
Preferences.php, apparently left behind detached.

Change 366181 had a related patch set uploaded (by Dzahn; owner: Dzahn):
[operations/puppet@production] scap/dsh: replace netmon1001->netmont1002 for librenms

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

Change 366181 merged by Dzahn:
[operations/puppet@production] scap/dsh: replace netmon1001->netmont1002 for librenms

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

Aklapper changed the subtype of this task from "Task" to "Feature Request".
Aklapper removed a subscriber: wikibugs-l-list.