Page MenuHomePhabricator

ScopedTypeaheadSearch: prefix searching may not handle main namespace correctly
Closed, ResolvedPublicBUG REPORT

Description

Originally discussed in this comment on gerrit, there may be something wrong with selecting a scope by prefix.

From @ArthurTaylor's initial comment:

The current implementation doesn't quite work for my config. I have:

$wgNamespaceAliases = [
  'Item' => NS_MAIN, // NS_MAIN=0
  ...
];

and mw.config.get('wgNamespaceIds') includes:

{ "": 0, ... }

since the main namespace is unprefixed. The result is that typing : in the search box sets the drop-down to Item - I guess we don't want that. Also, because ns0 is then mapped to "", the Item namespace alias gets overwritten and it's not possible to switch to the Item namespace by typing Item:.

The issue where just typing a : switches to Item has been fixed. The task here is to investigate anything strange that happens with the main namespace.

It is possible this behavior is the result of (mis-)configuration of a local wiki.

(proposed) Acceptance Criteria

  • we know whether this is an issue that affects production
  • if it's related to configuration, there's some documentation that helps people avoid this in other wikibases
  • if it's a more general problem, we identify the cause and fix it

Event Timeline

It seems that the config I have is also the config Wikidata has:

https://gerrit.wikimedia.org/g/operations/mediawiki-config/+/be4fab343a358c271d566f384baff6b042a53f7e/wmf-config/core-Namespaces.php#1892

	'+wikidata' => [
		'Item' => NS_MAIN,
		'Item_talk' => NS_TALK,
		'WD' => NS_PROJECT, // T43834
		'WT' => NS_PROJECT_TALK,
		'P' => 120, // T47079
		'L' => 146, // T195493
		'E' => 640, // T245529
	],

so this is at least a legitimate concern. Unfortunately, because the feature is not enabled on beta and the namespace configuration is not set on patchdemo, it might be difficult to test this on something other than a developer machine.

Okay. I had a dig into this, and it seems that the issue with my local setup was that I had not set:

	$wgWBRepoSettings['defaultEntityNamespaces'] = false;

in my DefaultLocalSettings.php after T291617 was completed. The change was notified in the RELEASE-NOTES-1.44 for Wikibase, but I obviously didn't read that at the time (or realised that it applied to my setup). With defaultEntityNamespaces true, the Item namespace was being registered both as 120 and as 0 on my local wiki, which was creating some confusion in the namespace mapping code in ScopedTypeaheadSearch.vue.

With the updated configuration, the feature works as expected - I can type item: and switch back to the Item namespace in the scoped selector. The setting is also explicitly set to false in the production config, so I'm optimistic that this will also "just work" in production.

I don’t think I can review anything here, my local wiki doesn’t have items in the main namespace to begin with (I actually use defaultEntityNamespaces).

Okay. Then considering this reviewed since it works for me and nobody else has reported it, and Lucas reports that the explanation is plausible.