Topic on Extension talk:Arrays

arrayprint prints "Array"

9
Kaffeeringe (talkcontribs)

It should be simple. My example-code:


{{#arraydefine:test|-1,-2,1,2,3|,}}
{{#arrayprint:test|<br/>|@@@@|Test: @@@@}}


Returns:

Test: -Array

Test: -Array

Test: Array

Test: Array

Test: Array


Why?


See my example.

Kaffeeringe (talkcontribs)

Ah! There's a bug:

Notice: Array to string conversion in PATH/htdocs/mediawiki-1.34.1/extensions/Arrays/ExtArrays.php on line 1220 Notice: Array to string conversion in PATH/htdocs/mediawiki-1.34.1/extensions/Arrays/ExtArrays.php on line 1220

Dinoguy1000 (talkcontribs)

Can you file an issue for this on Phabricator? If this is something that will affect any 1.34 wiki trying to use Ext:Arrays, it needs to be resolved.

Kaffeeringe (talkcontribs)
99.232.155.35 (talkcontribs)

Ran into this myself. "Array blah blah blah" instead of the expected "1 blah blah blah" as output. Now, trying to figure out what the mentioned legacy mode is...

Becasita (talkcontribs)

Extension:Arrays#Configuration

Add `$egArraysCompatibilityMode = true` to local settings. This will change other things, though. I wanted to point to the old docs, via diff link, but the abuse filter says it's harmful.

Dinoguy1000 (talkcontribs)
Brianfreud (talkcontribs)

I ended up using a rather clunky workaround, but it works, without the negatives of compatability mode. Only negative is that when you sort the array, 1, 2, and 3 will sort at the end, rather than the beginning.

In my case, {{{Bar}}} is a CSV string that I turn into an array.

{{#arraydefine:Foo|{{#replace:{{#replace:{{#replace:{{{Bar}}}|1|①}}|2|②}}|3|③}} }}

Then later:

{{#arrayprint:Foo|
|@@@@ |{{#vardefine:val|{{#replace:{{#replace:{{#replace:@@@@|①|1}}|②|2}}|③|3}} }} ... }}

99.232.155.35 (talkcontribs)

Just an update that 0 is also affected, though 4 through 9 are ok to leave 'unprotected'.

Reply to "arrayprint prints "Array""