Page MenuHomePhabricator

`$wgNamespacesToBeSearchedDefault` disregarded for anonymous users
Closed, InvalidPublic

Description

Setup

  • MediaWiki | 1.29.2 (3869ac0) 08:59, 15 November 2017
  • PHP | 5.6.30-0+deb8u1 (apache2handler)
  • MariaDB | 10.0.33-MariaDB-1~jessie
  • Semantic MediaWiki | 3.0.0-alpha (e48a508) 01:18, 15 November 2017

Issue
Semantic MediaWiki standardly includes the "Concept" and "Property" namespaces as namespaces to be searched by default (NamespaceManager.php). There are however cases where you would like to remove these two namespaces from the to be searched by default array. However, even though I added the following setting after the inclusion of Semantic MediaWiki

$wgNamespacesToBeSearchedDefault = [
        NS_MAIN => true,
        ];

the standard search is still also enabled for namespaces "Concept" and "Property" for anonymous users. This setting is however respected for logged in users.

Originally reported for Semantic MediaWiki on GitHub.

Example
Use the "advanced" profile on special page "Search" (public example)

Event Timeline

Kghbln updated the task description. (Show Details)

@Aklapper Do you happen to know someone who might at least assess the issue which in short is: $wgNamespacesToBeSearchedDefault is respected for logged in users but not for anonymous users.

@Aklapper Thanks to the info about this page. Did not know that existed. In this case I am not absolutely sure who to ask either. I guess Discovery appears the most appropriate.

@Smalyshev You appear to be driving the Discovery efforts at WMF code wise. Could you have a peep at this and/or point to somebody who may be even more appropriate to ask. Thanks a lot!

EBjune triaged this task as Medium priority.Jan 16 2018, 6:44 PM
EBjune subscribed.

We thought this had been addressed, we'll look into it.

We thought this had been addressed, we'll look into it.

Thanks a lot for triaging and your short feedback. Sounds like this issue is not unfamiliar to you. Yeah, a fix will be much appreciated.

I can confirm that the issue is still happening with the latest release, i.e.

  • MediaWiki 1.30.0 (d0c8f49) 19:49, 5 January 2018
  • PHP 5.6.33-0+deb8u1 (apache2handler)
  • MariaDB 10.0.33-MariaDB-1~jessie

I do not know how things are in master (1.31 to be).

Will this be a bigger issue? I guess it will be cool to get a fix at least into the upcoming 1.31 LTS

Any hopes for this. It is a rather troubling issue. Thanks for your time.

Hi @Kghbln, we have been actively working on search profiles in the context of refactoring our query parser (T191876), but I'm not sure if this specific issue has been addressed in the 1.31 release.

@dcausse, is there any insight you can share on this?

dcausse closed this task as Invalid.EditedApr 25 2018, 9:50 AM

As far as I can tell we properly honor $wgNamespacesToBeSearchedDefault on wmf wikis.
For example on es.wikipedia.org this config value is set to :

[
    100 => 1,
    104 => 1,
    NS_MAIN => 1
]

And when you search anonymously we properly search these namespaces.

Reading the SemanticMediawiki code you provided it really looks to me that the problem is there.
SMW seems to override the settings you set there. Since it uses the PHP + operator I bet you can circumvent the issue by setting:

$wgNamespacesToBeSearchedDefault = [
        NS_MAIN => true,
        SMW_NS_PROPERTY => false,
        SMW_NS_CONCEPT => false,
];

This should I hope resolve your problem.

Please reopen if you think I overlooked something.

@EBjune Thanks a lot for managing this issue and @dcausse Thanks a lot for digging into this issue.

Indeed the following setting helps the cause. It is a bit embarrassing since it was probably sitting in front of my face all the time

$wgNamespacesToBeSearchedDefault = [
        NS_MAIN => true,
        SMW_NS_PROPERTY => false,
        SMW_NS_CONCEPT => false
];

What probably got me off track is that setting

$wgNamespacesToBeSearchedDefault = [
        NS_MAIN => true
];

works for logged in users but not for anonymous users, which was what this issue was intended to address. I still think it is a bit strange to get this behaviour but it is not a big deal since there is a way out. However this is why I figured that adding this configuration parameter overrides all existing default settings to it.

Thanks to both of you for dealing with this and your assistance. Indeed very much appreciated!

One thing to consider that can be confusing with logged user vs anonymous is that logged-in users can save their namespaces preferences in Special:Search, so even after switching the $wgNamespacesToBeSearchedDefault to another set of values if some user had saved their namespace preferences the change you make to the config may not be visible for such user. It's perhaps what happened to you and caused even more confusion (just guessing).

Thanks a lot for the pointer. I think to have considered this and used a freshly created account when trying to work on this issue report. However I am not 100% sure about this any longer. Indeed, users can override - which is good. :)