Page MenuHomePhabricator

MediaWiki makes it possible to create tag '0', but it doesn't work
Open, 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.

Change 743562 merged by jenkins-bot:

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

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

I think this might have caused T303033.

I checked out this patch and my history does not show on my local docker. Checking out the patch just before this one and the history does show.

I confirm that. But when you uncollapse the menu and hit the button, it works. The database query seems to have 0=1 added.

matej_suchanek changed the task status from In Progress to Open.Mar 11 2022, 11:01 AM
matej_suchanek removed matej_suchanek as the assignee of this task.

So what's left?

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

[mediawiki/core@REL1_37] changetags: Fix management of a '0' tag

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

I was looking at backporting T311554: Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in ChangeTags.php on line 192 and then noticed that this change is what (rightly) changed from an if ( !$tags ) { to if ( $tags === '' ) { which the original version caught the false-y versions that didn't want to be caught (and some that did, including null).

Is it worth backporting? I started, and there's a few (trivial ish) conflicts. The Test file can just be removed, so it's just a few changes in ChangeTags.php that need sorting...

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

[mediawiki/core@REL1_35] changetags: Fix management of a '0' tag

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

Note that there was a regression T303033, so the fix for that needs to be backported, too.

Note that there was a regression T303033, so the fix for that needs to be backported, too.

Cheers. Mind having a look at the test failure on the two backports? I feel like I've missed something obvious :)

Change 809947 merged by jenkins-bot:

[mediawiki/core@REL1_37] changetags: Fix management of a '0' tag

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

Change 809948 merged by Reedy:

[mediawiki/core@REL1_35] changetags: Fix management of a '0' tag

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

Test wiki on Patch demo by Legoktm using patch(es) linked to this task was deleted:

https://patchdemo.wmflabs.org/wikis/a52ee2814b/w/