Page MenuHomePhabricator

RCFilters: Search for namespaces by number
Open, LowestPublic

Description

E.g. :0 for main namespace and :2 for user namespace.

This is a super-power user feature. It's minor but might be appreciated.

Related Objects

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Hi! I'm Usama Walayat, a GSoC 2026 applicant for the Wikifile-Transfer project. I'd like to claim this task. Here's my deep analysis and proposed solution:
Problem:
The Recent Changes filter panel allows users to filter by namespace using the namespace name (e.g., "Talk", "User", "File"). However, it does NOT support searching by namespace number (e.g., typing "1" to find the Talk namespace, or "6" for File). This is painful for experienced MediaWiki developers and admins who know namespaces by their numeric IDs — especially on wikis with many custom namespaces (100+) where the name may be in another language.
Root Cause:
In resources/src/mediawiki.rcfilters/ui/FilterMenuOptionWidget.js, the matchesFilter() method only compares the search string against the namespace label (human-readable name). It never checks against mw.config.get('wgFormattedNamespaces') which stores the numeric ID → name mapping.
My Proposed Solution:

In FilterMenuOptionWidget.js, extend the matchesFilter() method to also check if the search query matches the namespace's numeric ID
Fetch the namespace number from mw.config.get('wgNamespaceIds') which maps namespace names to numbers
Add a reverse lookup so typing "1" matches Talk, "6" matches File, "10" matches Template
Ensure the match is exact for numbers (not a substring match) to avoid false positives
Add a QUnit test covering: search by name still works, search by number returns correct namespace, invalid numbers return no results

I have JavaScript and MediaWiki extension development experience. May I claim this task?

Hi @Mattflaschen-WMF,
I am also interested in working on this task.

I saw the proposed approach using wgNamespaceIds and extending matchesFilter(). That makes sense.

I would like to help with implementation or testing (e.g., adding QUnit tests or handling edge cases like invalid inputs). Please let me know if I can contribute.

Thank you!

Pinging task authors, especially when their account is disabled, won't help. :) Please do read the text in the Comment field. Thanks.

Hi!
I have assigned this task to myself. I am a student participating in the Road to Wiki program. I will start working on this task and submit a patch for review.

Thank you.

Change #1312274 had a related patch set uploaded (by Keerthika P; author: Keerthika P):

[mediawiki/core@master] RCFilters: Support searching namespaces by numeric ID

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

I have implemented this feature and submitted a patch for review on Gerrit.

Patch: https://gerrit.wikimedia.org/r/c/mediawiki/core/+/1312274

What was changed:

The findMatches() method in FiltersViewModel.js was extended to support exact numeric ID matching when searching in the namespace view (triggered by :). Previously, only the human-readable namespace label was matched against the search query.

Files modified:

  • resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js — added exact match against namespace parameter name (numeric ID) in both the primary and fallback search loops
  • tests/qunit/resources/mediawiki.rcfilters/dm.FiltersViewModel.test.js — added QUnit tests for searching by namespace number

How it works:

  • Typing :0 now matches the Main namespace
  • Typing :2 now matches the User namespace
  • Typing :10 matches Template, etc.
  • Exact matching is intentionally used (not substring) to prevent false positives — e.g. typing 1 should not match namespaces 10, 11, 12.

Any feedback is welcome!