Page MenuHomePhabricator

VE doesn't let you enable it in namespaces whose labels happen to be ints
Closed, ResolvedPublic

Description

$wgVisualEditorAvailableNamespaces gets cast to an int very early.

Event Timeline

Jdforrester-WMF triaged this task as Medium priority.Mar 28 2019, 9:02 PM
Jdforrester-WMF created this task.

Change 499915 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[operations/mediawiki-config@master] [Wikimania] Enable VisualEditor in the 2019 namespace via ID

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

Jdforrester-WMF removed matmarex as the assignee of this task.Mar 28 2019, 9:16 PM
Jdforrester-WMF removed a project: Patch-For-Review.

Patch works around this bug, it doesn't address it.

Change 499915 merged by jenkins-bot:
[operations/mediawiki-config@master] [Wikimania] Enable VisualEditor in the 2019 namespace via ID

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

matmarex claimed this task.Mar 28 2019, 9:19 PM

This is because of a limitation of PHP, from https://wiki.php.net/rfc/convert_numeric_keys_in_object_array_casts :

The first of these, the array, is an ordered map of integer or string keys to arbitrary values. There is no overlap between integer and string keys in arrays; if a string fits the format /^(0|(-?[1-9][0-9]*))$/ and is small enough (PHP_INT_MIN ≤ n ≤ PHP_INT_MAX), it is converted to an integer key. Such strings are termed numeric strings.

I wouldn't be surprised if this isn't the only bug caused by a numerical namespace label.

We mostly refer to namespaces by ID in config options, $wgVisualEditorAvailableNamespaces is just weird. We can easily make it check if the value is a valid namespace name first, and if it isn't, then treat it as ID. I have a patch for this but Gerrit just went down.

Change 499945 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/extensions/VisualEditor@master] Treat ambiguous values in $wgVisualEditorAvailableNamespaces as names

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

Change 499945 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] Treat ambiguous values in $wgVisualEditorAvailableNamespaces as names

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

ppelberg closed this task as Resolved.May 24 2019, 11:04 PM