Page MenuHomePhabricator

#arrayunique causes #arraysearch to return incorrect results
Open, Needs TriagePublic

Description

Results from arraysearch are incorrect when used on an array after arrayunique has been run.

Example:

wiki
{{#arraydefine:abc|10, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 6, 0, 7, 1, 0, 9, 0, 5, 12, 11}}
#{{#arraysearch:abc|1|0|1|0}}
#{{#arraysearch:abc|2|0|1|0}}
#{{#arraysearch:abc|3|0|1|0}}
#{{#arraysearch:abc|4|0|1|0}}
#{{#arraysearch:abc|5|0|1|0}}
separator
{{#arrayunique:abc}}
#{{#arraysearch:abc|1|0|1|0}}
#{{#arraysearch:abc|2|0|1|0}}
#{{#arraysearch:abc|3|0|1|0}}
#{{#arraysearch:abc|4|0|1|0}}
#{{#arraysearch:abc|5|0|1|0}}

Results:

1. 1
2. 0
3. 0
4. 0
5. 1
separator
1. 0
2. 0
3. 0
4. 0
5. 0

If this bug were not present, the second result list would match the first.

A temporary workaround is to redefine the array after it has been uniqued: {{#arrayunique:abc}}{{#arraydefine:abc|{{#arrayprint:abc}}}} This will cause array def to again return correct results from arraysearch.

This was observed using MediaWiki 1.33.1 and Ext:Arrays 2.1.0. @Dinoguy1000 tested it on a MediaWiki 1.31.1/Ext:Arrays 2.1.0 wiki, where it worked as expected. Please see https://www.mediawiki.org/wiki/Topic:Vesd5hwungagff9x for the original report.