Page MenuHomePhabricator

MediaWiki makes it possible to create tag '0', but it doesn't work
Open, In Progress, Needs TriagePublic

Description

I created tag called '0' via https://test.wikipedia.org/wiki/Special:Tags. It doesn't appear to be possible to disable it again:

https://test.wikipedia.org/w/index.php?title=Special:Tags/deactivate&tag=0 shows the following:

image.png (331×1 px, 16 KB)

The Special:Tags page does not show a delete link:

image.png (122×1 px, 5 KB)

Manually constructing the URL shows a valid deletion form at https://test.wikipedia.org/w/index.php?title=Special:Tags/delete&tag=0. It also works fine when submitting (just tested that).

Event Timeline

matej_suchanek changed the task status from Open to In Progress.Dec 3 2021, 9:25 AM
matej_suchanek claimed this task.

Change 743562 had a related patch set uploaded (by Matěj Suchánek; author: Matěj Suchánek):

[mediawiki/core@master] Fix management of '0' tag

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

Legoktm renamed this task from MediaWiki makes it possible to create tag '0', but I can't disable it to MediaWiki makes it possible to create tag '0', but it doesn't work.Dec 4 2021, 9:38 PM

I did some testing, even with the current patch there are still issues:

  • Using ?tagfilter=0 on Special:RecentChanges doesn't work
  • Enhanced JS on Special:RecentChanges doesn't autocomplete a tag of 0
  • API action=query&list=tags returns the tag 0 as a JSON number, not a string

Not sure if it's all related, I'm going to poke at the API issue now.

The API issue is because the tag name is used as an array key. A quick skim shows a few other places where this happens, all of which would need strval() fixes. I'm wondering if it would be easier to just not allow creating tags that are integers via isTagNameValid(), which both takes care of the '0' issue, plus all other integers being a different type.