Page MenuHomePhabricator

Adopts the Wikidata label when it differs from what they typed
Closed, ResolvedPublic2 Estimated Story Points

Assigned To
Authored By
hueitan
Aug 28 2026, 9:42 AM
Referenced Files
F105416432: image.png
Sep 29 2026, 10:16 AM
F105416409: image.png
Sep 29 2026, 10:16 AM
F105415966: image.png
Sep 29 2026, 10:16 AM
F105415951: image.png
Sep 29 2026, 10:16 AM
F102893515: image.png
Sep 14 2026, 6:58 AM
F102893480: image.png
Sep 14 2026, 6:58 AM
F101009850: image.png
Aug 31 2026, 10:09 AM
F100430747: image.png
Aug 28 2026, 10:54 AM

Description

follows the change on T432111: Show error when the entered title is invalid

Steps to reproduce problem
  1. https://test.wikipedia.org/wiki/Special:NewArticle?newarticletitle=KHK2017_165
  2. Select the first option
  3. In this case, you are shown a suggestion of KHK2017 165 (Astronomical object)
Environment

Wiki(s): https://test.wikipedia.org ArticleGuidance – (6e031c0) 12:37, 9 July 2026.

Screenshots

badtitle.png (1,097×379 px, 29 KB)

Design

It's due to the fact that we treat a Wikidata label and a Wikipedia page title as the same string.

They pick a subject whose Wikidata label is illegal

image.png (920×1,930 px, 159 KB)
image.png (920×1,930 px, 137 KB)

Direct Special:NewArticle still adopts the Wikidata label when it differs from what they typed. Keep that rule, but only adopt a legal label: strip # < > [ ] { } |. (DEV: T436341#12270300, use mw.Title instead)

  • Type KHK2017, pick [KHK2017] 369 → page title is KHK2017 369 (keep the number; drop the brackets).
  • Type KHK2017 369, pick [KHK2017] 369 → title stays KHK2017 369 (cleaned label matches typed).
  • Do not send an illegal string to the “does this title exist?” check. invalid from the API is not “exists.”
  • After pick, use the normal next step (subject already here, real title conflict, notability, or sources).

Event Timeline

hueitan set the point value for this task to 2.

when user type the invalid title in the Update title step,
the validation happens on the "checkPagesExist"

the api response invalidreason (invalid characters) but UI is showing article already exist, we should show the invalid title message instead, reuse the script in T432111: Show error when the entered title is invalid and prevent sending the checkPagesExist api when it's already invalid.

image.png (914×848 px, 89 KB)


do this in a separate patch

Change #1332679 had a related patch set uploaded (by Huei Tan; author: Huei Tan):

[mediawiki/extensions/ArticleGuidance@master] Sanitize selected article label using mw.Title.newFromUserInput

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

DEV: instead of removing the invalid character manually, use mw.Title. newFromUserInput to produce a title that MediaWiki will accept as legal.

image.png (1,398×498 px, 68 KB)

Change #1332683 had a related patch set uploaded (by Huei Tan; author: Huei Tan):

[mediawiki/extensions/ArticleGuidance@master] updatetitle: Validate title and show error on onvalid input

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

Nikerabbit moved this task from Backlog to Pre-Visual Editor on the Article-Guidance board.

Change #1332683 merged by jenkins-bot:

[mediawiki/extensions/ArticleGuidance@master] updatetitle: Validate title and show error on invalid input

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

Change #1332679 merged by jenkins-bot:

[mediawiki/extensions/ArticleGuidance@master] Sanitize selected article label using mw.Title.newFromUserInput

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

Nikerabbit subscribed.

This doesn't seem to work:

Step 1 (following the link):

image.png (1,873×1,310 px, 89 KB)

Step 2 (choosing the only option):

image.png (1,873×1,310 px, 116 KB)

It still claims the article exists.

The patch is not deployed yet. should be this week.

Nikerabbit changed the task status from Open to In Progress.Sep 21 2026, 6:34 AM

Entered KHK2017 165 --> picked [KHK2017] 165 --> title is (KHK2017) 165

image.png (1,780×520 px, 72 KB)

image.png (1,815×847 px, 193 KB)

So this appears to work as expected.

Regarding the validation,

I entered KHK2017 165 # and that does not show any error.

image.png (1,798×544 px, 66 KB)

But then I enter: KHK2017 165 #^, and I see the title validation error.

image.png (921×342 px, 28 KB)

I'm not sure if that's the expected behavior.

Tests were conducted on https://test.wikipedia.org/wiki/Special:NewArticle

I entered KHK2017 165 # and that does not show any error.
But then I enter: KHK2017 165 #^, and I see the title validation error.

I'm not sure if that's the expected behavior.

I think it's expected behaviour, we don't accept the title having the fragment, so in the case KHK2017 165 #^, remove either # or ^ will make the title valid.
https://gerrit.wikimedia.org/g/mediawiki/extensions/ArticleGuidance/+/548c1534ec6a4b92f8c631f233b2d7ecb4888f89/resources/ext.articleguidance.newarticle/utils/title.js#21

but if we type nyc#, we will get the final title nyc in the last step, should we just completely make the title invalid when # is given?

submit patch https://gerrit.wikimedia.org/r/c/mediawiki/extensions/ArticleGuidance/+/1348391

This now tests well on https://test.wikipedia.org/wiki/Special:NewArticle. Its rolling out via the train this week.