Extension talk:Arrays/archive 2/Flow export

Old messages until March 2011 are archived.



Using arrayunique with a different delimiter

Is there a chance to use arrayunique with another delimiter other than a comma. In our case, the array content contains already comma's so that when arrayunique is applied not all unique's are filtered correctly due to the assumption that arrays are divided by a comma. A possibility for arrayunique to use a different delimiter (as in case of arraydefine) would be much appreciated. MWJames 05:23, 2 July 2011 (UTC)

I can't see the problem here. Arrayunique just modifies an existing array, all the array entries are already specified by arraydefine where you simply choose another separator as the comma. This example works just fine with the current version:
{{#arraydefine:test | a,aa<>bb,b<>c,c,c,c<><><>,,<>,,<>eee,<>eee, |<> }}
{{#arrayprint:test|<br/>}}
-------
{{#arrayunique:test}}
{{#arrayprint:test|<br/>}}
Danwe 10:56, 7 July 2011 (UTC)

Any wishes for Extension:Arrays v2 ?

I am thinking about re-writing Array extension right now. There are a few functions I'd like to behave differently. Since this will break compatibility with some old functions, I would rename this new extension to "Extension:Arrays 2". Things I want to change:

  • #arrayprint should not give a message if the array doesn't exist, just return an empty string. #arrayexists should be used if one is not sure.
  • #arrayreset should use | instead of , as delimiter, just like hashreset.
  • #arrayindex options will be removed, instead third parameter simply is the default value (without any default= in front). It should only be expanded when needed.
  • #arrayindex should return its default also in case of existing index but empty value. This makes the function consistent with Variables #var and hash tables #hashvalue.
  • #arrayunique, #arraymerge, #arrayunion, #arraymerge, #arrayintersect and #arraydiff will be able to work with more than just two arrays like all of Hash Tables similar functions work right now.
  • #arraysearch will no longer return -1 if nothing found, it will return an empty string so it can be used with #if. The yes and no parameters will stay but only be expanded when the actual case happens (same behavior as in #if, this actually is a bug which should be fixed right away). Danwe 16:28, 10 November 2011 (UTC)
First you might not need to renamed it as you can set a release tags something like Tag for version 0.1 (SVN trunk REL_0_1) which becomes a clear release without interfering with previous/future versions.
I don't know how this is technical done but you might ask User:Jeroen De Dauw, he uses in his Semantic Image Input and Push extension. MWJames 16:41, 10 November 2011 (UTC)
Yeah, you might as well just modify the existing code - I don't think it's being maintained anyway. Yaron Koren 19:40, 10 November 2011 (UTC)
I have put an ArrayExtension 1.4 alpha (r103716) into SVN and have an 2.0 alpha in my local workspace. I am just thinking about the implications of documentation. I mean quite some points on the documentation must be updated. BUT I have also put an compatibility mode into the extension which allows to switch back to the old behavior as far as possible (pretty much everything should work but its a hell of a lot to test so I might have overlooked some minor details). So I am still wondering whether creating a new extension called Arrays, referring to ArrayExtension wouldn't be more suitable. On the other hand, I would strongly recommend updating to 2.0 since a huge bug will be fixed (array store per Parser object introduced, this will prevent things like special page inclusion resetting all arrays). Danwe 13:45, 20 November 2011 (UTC)
If you fear for the documentation, why not create a archive subpage where you copy the current documentation and the link to the SVN __REL Tag. In the meantime made a note using {{Notice| ...}} template to advice people on that matter. You also could have a section where you explain migrating from ... to 2.0. While I still think staying with ArrayExtension is a better choice than creating a new extension, the final call is yours. MWJames 15:28, 20 November 2011 (UTC)
There is one additional advantage of renaming the extension - I never liked the name "ArrayExtension"; there's no point having "extension" in the name. So maybe something like "Arrays" is the way to go. Yaron Koren 16:25, 20 November 2011 (UTC)
+ renaming it to Arrays. We all know that it is an extension. [[kgh]] 20:10, 20 November 2011 (UTC)
HAving a second extension isn't really my first choice, renaming would be a good thing to do though. Simple to rename this extension page and the name, but what about the directory in SVN/extension directory and ArrayExtension.php ? Would it be wise to rename them or should they remain the same so people won't just place the new folder in their extension directory without noticing that the old version still is active since they had to change localsettings first...? Danwe 20:41, 20 November 2011 (UTC)
I think a clear cut would be the best. Thus I would move it to Arrays. Admins have to edit their LocalSettings.php anyway at some time, so catering for the old setting is not really a must. It is also their business to delete old folders etc. so you should not worry to much about this. If they are able to install this they will also be able to make changes to the installation. At least I believe so. Cheers [[kgh]] 19:49, 21 November 2011 (UTC)
Version 2.0rc2 is out now. You can test the new breaking changes and the compatibility mode which attempts to keep old behavior as far as possible. I have created Extension:Arrays/Pre_2.0_Documentation for documentation applying to Pre 2.0/1.4 alpha versions and 2.0 in case compatibilty mode is active. See the 2.0rc2 RELEASE-NOTES for a complete list of changes. Furthermore, Extension:HashTables 1.0 alpha is in a similar state and can be tested as well. Even though HashTables can do with just one optional compatibility mode behavior on hashprint since I haven't designed it exactly like ArrayExtension back then. Danwe 18:12, 4 December 2011 (UTC)
I have updated the documentation now. Pre 2.0 behavior documentation can be found under Extension:Arrays/Pre 2.0 Documentation. Danwe 20:25, 4 December 2011 (UTC)

Silent Print?

Hi.

Great extension :) Is there a way to do a silent arrayprint?

I have the following:

{{#arraydefine:dates|{{#ask:[[Category:Events]][[Title::{{{Title|}}}]] |?Event Dates= |mainlabel=- |sep =, |limit=1000}} |,|unique}}
{{#arrayprint:dates|,|@@@@|{{#set:Month={{#time:M|@@@@}}}}}}

This takes the array of dates, strips out the month part of the string and sets it into a SMW property. This works, but you also get ,,,,,,,,,,, displayed. Is it possible to set arrayprint not output to screen?

Thanks! Mitchelln 11:27, 22 November 2011 (UTC)

Yeah, just remove the , from Parameter 2 ;) {{#arrayprint:dates| |@@@@|{{#set:Month={{#time:M|@@@@}}}}}}. By the way, using in a query, in case Title is not given, This will give an rather ugly result. Danwe 12:49, 22 November 2011 (UTC)
Hi Danwe.
Great, thanks for that :) Title is a mandatory field, so no problem there :) Mitchelln 16:31, 22 November 2011 (UTC)

Bug in arraysearch?

Given the following:

{{#arraydefine: test | item1, item2}}
{{#arraydefine: test2 | item1}}

These arraysearches:

arraysearch1: {{#arraysearch: test | item2}} 
arraysearch1yesno: {{#arraysearch: test | item2 | 0 | yes | no }}
arraysearch2: {{#arraysearch: test2 | item2}} 
arraysearch2yesno: {{#arraysearch: test2 | item2 | 0 | yes | no }}

Will produce:

arraysearch1: 1 
arraysearch1yesno: yes
arraysearch2: 
arraysearch2: arraysearch1yesno: -1

The last array search should produce "no" instead of -1. Is this a bug?

Badon 20:42, 14 December 2011 (UTC)

Indeed a bug. Fixed in r106299 - nested alternative if-else syntax can be dangerous... Thanks for reporting! Danwe 01:31, 15 December 2011 (UTC)
Thanks for fixing that so fast! I would have liked to add another notch to my bugzilla bug-hunting belt - If only I could always be so disappointed, haha :) Badon 05:52, 16 December 2011 (UTC)
I think I've found another bug:
  • {{#arraydefine:platform | I,So,4,Sa,P }}
  • {{#arrayprint: platform | xxx }} # shows "IxxxSoxxx4xxxSaxxxP" (debugging)
  • {{#arraysearch:platform code|I}} # Shows 0
  • {{#arraysearch:platform code|So}} # Shows nothing, blank, zip
  • {{#arraysearch:platform code|4}} # Shows nothing, blank, zip
  • {{#arraysearch:platform code|Sa}} # Shows nothing, blank, zip
  • {{#arraysearch:platform code|P}} # Shows nothing, blank, zip
Currently I'm on head at https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Arrays.githttps://gerrit.wikimedia.org/r/p/mediawiki/extensions/Arrays.git (2c2ea47684f7769ce8b8d3647e4772cfb90fd5df)
Thank you! Dan Bolser (talk) 12:53, 5 March 2013 (UTC)
Gah... actually the above works... the issue was combining #arraysearch within an #arrayprint, which I suspect is expected to fail? Dan Bolser (talk) 00:17, 7 March 2013 (UTC)
Doesn't have to fail necessarily. Can you post your code please? Danwe (talk) 21:59, 29 March 2013 (UTC)

Arrays patch

Just FYI:

https://bugzilla.wikimedia.org/show_bug.cgi?id=34358 72.229.228.226 04:40, 13 February 2012 (UTC)

Submitted patch for new function: arraysum

Hi, I submitted a patch for a new function (arraysum) https://gerrit.wikimedia.org/r/#/c/9857/ Toniher (talk) 20:01, 3 June 2012 (UTC)

Thanks for the commit, but I am really not sure whether the function is necessary.
{{#expr: {{#arrayprint: arr | + }} }}&lt;/pre&gt;
will do almost the same job (assuming we just have numeric values, otherwise it gets a bit more complicated) with just two parser functions being called and shouldn't make much of a difference performance-wise. You can also just replace the <code>+</code> with a <code>*</code> or whatever and you would have an ''arrayproduct'' as well.
I really think we shouldn't further increase the number of array functions for such trivial stuff since all functions need to be maintained and documented and understood by potential users. What do you think? [[User:Danwe|Danwe]] ([[User talk:Danwe|talk]]) 22:16, 5 June 2012 (UTC)
::Hi Danwe,
::I didn't think about that solution.
::You're right, the only advantage about adding the parserfunction is that, since it uses native PHP function http://php.net/manual/en/function.array-sum.php (which seems to be resilient to errors, as far as I have tested), if some inputs are not numbers, it will simply work with the ones which are. But this can be a problem otherwise as well, since it can make difficult to find input errors.
::No strong opinion. [[User:Toniher|Toniher]] ([[User talk:Toniher|talk]]) 16:08, 6 June 2012 (UTC)
:::Alright, I have abandoned the change for now. I think maintainability and keeping a manageable amount of parser functions should be the higher goal, except the gain in performance or the range of new possibilities introduced by a new parser function would be so extreme that it would justify its introduction. Performance by the way could possibly further improved by simply joining all array members when only the separator parameter is set. I believe right now we always do the whole action which possibly slows things down a lot. [[User:Danwe|Danwe]] ([[User talk:Danwe|talk]]) 10:35, 14 June 2012 (UTC)

== #arrayprint and semantic properties ==

Hi, 
I'm trying to set values for a semantic property to the (unique) set of values in an array, which is itself the result of a semantic query. I can define the array properly from a query using #arraydefine but cannot get #printarray to produce something that can be used as a property value. I've tried a few different ways but cannot seem to find the right syntax. 

#printarray by itself prints a good array but it passes something like <code>:Value|Value</code> when I set it as a semantic property. 

See my example on [http://scratchpad.referata.com/wiki/Front-wheel_drive scratchpad.Referata] for an example. [[Special:Contributions/User:CWinDC|CWinDC]] 17:27, 17 August 2012 (UTC)
:Just use <code>link=none</code> in your query. Or even better, use the [http://semantic-mediawiki.org/wiki/Help:Array_format Array result format]. [[User:Danwe|Danwe]] ([[User talk:Danwe|talk]]) 10:37, 20 August 2012 (UTC)
::Thanks! That cleaned things up right away. ...er, rather after I re-saved the page to take the template parameters. 
::I can't use the Array result format, tho. It doesn't disassociate the multiple-values from a queried page as unique array entries. But, I suppose that comment belongs on '''that''' talk page, not this. [[Special:Contributions/CWinDC|CWinDC]] 13:33, 20 August 2012 (UTC)

== Append items to an array ==

What's a good method to go about appending items to an array?  Assuming I start with an empty array of values, should I be creating a temporary array to hold the new value and then merge it into the "permanent" one?  I feel like I am missing something obvious.  Thanks! [[Special:Contributions/131.167.254.100|131.167.254.100]] 21:34, 1 April 2013 (UTC)
:The additional values have to be in a temporary array, yes:
:<syntaxhighlight lang='text'>{{#arraydefine:array1 |a,b,c}}
{{#arraydefine:array2 |d,e,f}}
{{#arraymerge:array1 |array1| array2 }}
Wouldn't be hard to add a parser function just adding/removing values from an array but so far I didn't feel the need for it. Usually I get those values from somewhere and have to turn them into an array anyhow. Danwe (talk) 14:46, 20 April 2013 (UTC)

Create Tablerows in an Array

Hello Guys,

i want to let arrayprint create a Table Row. I try'd some things like this:

{{#arrayprint:Test|
{{!}}-
{{!}}
|@@@@|{{dot}}[[@@@@]]}}|*Nothing}}

and many More things, to let the array create a new Tablerow. But it didn't works. This is my basic Code:

{|width="100%" valign="top" align="top" class="SE-Heaventable" border="1"
!Test
|-
|{{#if: {{{Test|}}}|
{{#arraydefine:test|{{{Test|}}}}}
{{#arrayprint:Test|<br>|@@@@|{{dot}}[[@@@@]]}}|*Nothing}}
|}

Have anyone an idea how can i let work the array to get a tablerows? Yukii (talk) 06:41, 28 April 2013 (UTC)

Not sure how it works with using the special table syntax right now (quite sure I did it before using array or loops though) but I'd recommend you to use the HTML table syntax instead in any case. The MW table syntax is just an abortion. Danwe (talk) 15:48, 2 May 2013 (UTC)
One way to deal with this type of issue is to use something that will be considered whitespace by HTML, but will not be considered whitespace (and therefore not be trimmed) by arrayprint:
{{#arrayprint:Test|&amp;#32;
{{!}}-
{{!}}|@@@@|@@@@|}}
...the &#32; here is seen as "not whitespace" by arrayprint and MediaWiki, so it, and the newline that follows, is not trimmed...but it's an HTML escape sequence for a space character, and HTML largely ignores whitespace characters, so the extra space at the end of the preceding line is ignored by web browsers.
Don't forget that this way of printing table rows will only give you the new table row and beginning of element symbols between rows, so you need to start a row and an element before the call to this template, i.e. the full table would look like:
{|
|-
|{{#arrayprint:Test|&amp;#32;
{{!}}-
{{!}}|@@@@|@@@@|}}
|}
(Except, of course, that you'll be parsing @@@@ into a full row of table content, unless this is a simple list displayed in table format.)
I have one template on my wiki that prints table rows via arrayprint without using this trick, but I can't for the life of me figure out why it's working, and I think this trick is probably safer than whatever is making that template work. If you end up accidentally adding an extra line of whitespace in the table, that gets ignored, but a missing line of whitespace causes big problems. Verbatim9 (talk) 23:04, 11 April 2014 (UTC)

Newbie question about 2D arrays

This is a wonderful extension, the potential of which I've only recently begun to explore. There's one use case where I hope this extension could offer a solution. I'm trying to set up a template in such a way that subarrays are split into two (or more) unequal parts that can then be further processed by parser functions used in the same template. For example:

input: "A:1; B:4; G:7;" (etc.)
=>
output: "(A) with 1, (B) with 4, (G) with 7" (etc.)

(preferably, in one function without an intermediate key)

How should I go about? Cavila (MW 1.19.2, MySQL 5.1.66, Php 5.3.3-7, SMW 1.8, SF 1.5.2} 18:38, 14 June 2013 (UTC)

Multi-byte characters are not safe

Currently, the arrays extension does not properly handle multi-byte characters (though this may be a shortcoming of regex, I don't know):

Character: ナ
Size: {{ #len: ナ }}
Array size: {{ #arraydefine: array | ナ | // }}{{ #arraysize: array }}

results in

Character: ナ
Size: 1
Array size: 5

Note that attempting to use #arrayprint to view the array results in the parse of the entire page's contents being aborted. ディノ千?!? · [[User talk:Dinoguy1000#top|☎ Dinoguy1000] 19:55, 1 March 2014 (UTC)

rev:45734 may be relevant for fixing this bug. ディノ千?!? · [[User talk:Dinoguy1000#top|☎ Dinoguy1000] 08:34, 21 March 2014 (UTC)
Don't suppose this could get some attention? ディノ千?!? · [[User talk:Dinoguy1000#top|☎ Dinoguy1000] 09:42, 5 November 2014 (UTC)
I guess we should use mb_split instead of preg_split here and perhaps other mb_ functions throughout the code. Not really familiar with those yet and unaware of unwanted side-effects.
Not really committing too much time to MW coding these days. If anyone wants to commit a patch for this - this should contain tests though!
I am willing to review and merge. I am also available for hire to tackle this issue throughout the extension if anyone is willing to compensate for it. Danwe (talk) 02:09, 11 December 2014 (UTC)

Printing with spaces in delimiter

Is there any way to print a space in the delimiter, or to prevent spaces from being lost if the delimiter borders on a space?

I have to parse a string to escape wiki links, i.e., take in a string like "something with a [[link]]", split it at the [[ using /\[\[/ as the delimiter, and print "something with a $OpenWikiLink$link]]", but what I get is "something with a$OpenWikiLink$link]]", trimming off the space.

At the moment, I'm working around this by escaping all spaces to &#32;, by splitting the string with /\s/ as the delimiter and printing with &#32; as the delimiter, but replacing real spaces with &#32; isn't ideal, as spaces do sometimes have meaning in wikitext.

I'd prefer, if it's not possible to avoid loss of spaces near the spilt, to also escape the spaces, and then be able to split on my escape for spaces and print real spaces as the delimiter, but I haven't been able to find a way to print spaces in the delimiter...even tried to create a template {{space}} that contains a single space, and use that as the delimiter, but it doesn't seem to work. Verbatim9 (talk) 18:24, 3 April 2014 (UTC)

This indeed might be a problem in a few rare cases. The parser function design (as generally most anything related to wikitext) for this is not very good though too late to change it due to compatibility issues.
This might help though: Have you tried to use <nowiki> </nowiki> as your delimiter? Danwe (talk) 15:11, 17 September 2014 (UTC)

Counting the number of occurences of a value in an array?

I am looking for a solution to count the number of occurrences of a string in an array. PHP has "array_count_values", did anyone make this available already for Arrays in MW?

[Apple, Pear, Apple, Banana] Apple = 2, Banana = 1, Pear = 1.

Thanks,

Best wishes,

Timo 82.161.136.28 11:24, 30 May 2014 (UTC)

Assuming your wiki has Extension:StringFunctions enabled, you could use wikia:yugioh:Template:Count. I don't think there's a built-in solution, though. ディノ千?!? · [[User talk:Dinoguy1000#top|☎ Dinoguy1000] 19:31, 30 May 2014 (UTC)
I've added floor to get rid of the decimals.
This works for strings indeed, my problem is counting occurrences of a string in an array of strings. When I copy those into 1 string to let {{count}} work, the string has gotten to long.
Your idea may help me though, I have to implement something to loop through the array counting for each element of the array.
Thanks! 82.161.136.28 10:25, 2 June 2014 (UTC)
Simply use arraysearcharray in combination with arraysize. Danwe (talk) 15:01, 17 September 2014 (UTC)

arraysearcharray regular expression

does arraysearcharray support regular expressions without another extension? or does it require one of the regex extensions to be installed.

Sorry it's not very clear from the help page, I tried a few of the examples but can't seem to make the regular expressions work which would seem to indicate another extension is required?

Thanks for the clarification and help 220.233.17.248 11:43, 4 September 2014 (UTC)

Not sure if it needed the regex extension or not but i installed one JIC. The example listed under searcharraysearch seems to be backwards? ie the written text doesn't match the actual code example. X and a seem to be transposed in one place or the other
Anyways got it working now and most helpful function for manipulating arrays :) 220.233.17.248 11:20, 6 September 2014 (UTC)
No, there's no need for any regular expression extension. Danwe (talk) 14:53, 17 September 2014 (UTC)

Not so pretty

I'm having some problems with "print=pretty". Semantic Forms automatically places the delimiter at the end of the last item. This usually has no consequences, but with "print=pretty" the result becomes ugly: "a; b; c; d;" is rendered as "a, b, c, d and". Cavila (MW 1.22, MySQL 5.5.37-0, Php 5.4.4-14 squeeze, SMW 1.9.2, SF 2.7) 21:48, 6 October 2014 (UTC)

Looks like the last element in your array is an empty string? You could use #arrayunique before printing. Danwe (talk) 17:31, 4 November 2014 (UTC)
Probably so - will try that, thanks! Cavila (MW 1.22, MySQL 5.5.37-0, Php 5.4.4-14 squeeze, SMW 1.9.2, SF 2.7) 09:13, 5 November 2014 (UTC)

$egArraysExpansionEscapeTemplates

I believe this setting defaults to NULL. What would look a typical setting look like? [[kgh]] (talk) 17:04, 3 December 2014 (UTC)

Documentation at Extension:Arrays#Configuration states the default values are different. Though null would probably make more sense. I might have changed this and forgot to update documentation. I might look into this again.
Good values would be the ones documented in the link above if you have those templates in your wiki (Template:!, Template:(( Template:)) and Template:=) Danwe (talk) 10:54, 9 February 2015 (UTC)
Thanks for you info. Yeah, probably null making more sense got me confused somehow. No worries. I just had a look: The templates are indeed set by the extension and not null. Thus the docu is ok. [[kgh]] (talk) 19:47, 16 February 2015 (UTC)

#arraydefine and #arrayindex (Extension:Arrays) vs #explode (Extension:ParserFunctions)

In the following use case, the same can be achieved with either the Arrays extension or ParserFunctions:

{{#arraydefine:@@@|a--b|--}}
{{#arrayindex:@@@|0}} and {{#arrayindex:@@@|1}}
{{#explode:a--b|--|0}} and {{#explode:a--b|--|1}}

(result: a and b)

Does anyone know which is the least expensive approach here? Cavila (MW 1.22, MySQL 5.5.37-0, Php 5.4.4-14 squeeze, SMW 1.9.2, SF 2.7) 08:16, 6 February 2015 (UTC)

IMO arraydefine is the least expensive approach here because it will divide the string to array only once Pastakhov (talk) 08:27, 6 February 2015 (UTC)
OK, thanks! I would have expected the more verbose approach to be slightly more expensive, but that logic does not hold here.
(Perhaps I should emphasize that the pattern above is actually a subarray that is repeated a number of times on the same page - being wrapped in a template with the #arraymap parser from Semantic Forms - but then the issue would have been immaterial if the pattern occurred only once.) Cavila (MW 1.22, MySQL 5.5.37-0, Php 5.4.4-14 squeeze, SMW 1.9.2, SF 2.7) 08:49, 6 February 2015 (UTC)
The first approach:
  • arraydefine in PHP calls function explode (expensive) and saves result (cheap).
  • arrayindex gets saved result (cheap).
There is 1 expensive operation
----
The second approach:
  • explode in PHP also calls expensive function explode but here it was twice for same string because it didn't save the result between calls.
There are 2 expensive operations
Cheap operations are irrelevant here.
In fact there will be no difference, since the most expensive operation here is the usage of magic words.
If performance is so critical for you, it can be solved by Extension:PhpTags. Pastakhov (talk) 09:41, 6 February 2015 (UTC)
Thanks a lot for your help and explanation. I never looked that critically at performance actually, but something told me that maybe I should at least investigate the options. Cavila (MW 1.22, MySQL 5.5.37-0, Php 5.4.4-14 squeeze, SMW 1.9.2, SF 2.7) 10:15, 6 February 2015 (UTC)
You are welcome. It will better if you check it in practice. You should make both variants and compare "CPU time usage" in report in source of html page. Thus you will get the most precise answer :-)
Good luck! Pastakhov (talk) 10:24, 6 February 2015 (UTC)

Erroneous behaviour with inline if for empty arraydefine value constructed from template values

Please forgive me, but I cannot fathom the logic to produce the desired result by using the provided documentation for primarily this, and some related template logic extensions.

I have produced a template which allows me to set variables which then are constructed into an array using a loop function. I cannot figure out how to not define an array value if it is not defined in the template.

I have produced an example of the error; towards the bottom of the table you will see that a table row for "Onset" is erroneous. I have also isolated the relevant code

Instead of the expected result of a hidden table row, I am seeing that the array value is being set as the template's variable name instead.

Any help would be gratuitously appreciated by the universe at large.

Love and waffles, PJ.

Relevant documentation

if

{{#if: test string | value if test string is not empty | value if test string is empty (or only white space) }}

arraydefine

// Define a one-element array named 'e', using ';' as delimiter	
{{#arraydefine:e|apple, pear|;}}

~Φנσѕєρнєяυм wtc 22:48, 6 September 2015 (UTC)

fixed. You should define empty default value for parameters Pastakhov (talk) 08:08, 7 September 2015 (UTC)
I am forever in your debt! :) ~Φנσѕєρнєяυм wtc 12:46, 7 September 2015 (UTC)

I'm trying to develop a template which converts multiple image inputs into a slideshow gallery. So that things don't get confused, the array is delimited by comma's: within each "entry" itself, there are colons to separate particular values so they can be formatted. The problem is that, while the array is formatted properly, the array does not format the output as expected. The first entry goes fine, but then it confuses the rest of the entry, causing the slideshow to stop formatting as expected. The template can be found here, any advice is appreciated: http://impressionsgames.wikia.com/wiki/Template:Infobox/Slideshow 81.131.80.21 (talk) 15:13, 20 September 2015 (UTC)

I should point out that I tried changing the printing explosions to use semi-colons which did nothing to solve the problem. If I use just a plain |, the template doesn't work and if I use {{!}} on the page, the problem I mentioned occurs. 81.131.80.21 (talk) 15:24, 20 September 2015 (UTC)
Nevermind. Found the solution. Ignore the question. 81.131.80.21 (talk) 15:25, 20 September 2015 (UTC)

Using multiple multiple-character delimiters

I tried the main approaches suggested here: http://stackoverflow.com/questions/97435/regexes-and-multiple-multi-character-delimeters,

{{#arraydefine:ARRAY|white sand, tall waves and warm sun|\s*(?:\band\b|,)\s*}}

{{#arrayprint:ARRAY|+}}

but they do not seem to work with this extension. What's the catch (or error on my part more likely)? Cavila 14:18, 14 November 2015 (UTC)

That's because you do not use the arraydefine regular expression syntax correctly. If you want to use a regular expression as delimiter you had to use /\s*(?:\band\b|,)\s*/ Danwe (talk) 13:57, 10 July 2016 (UTC)

delimiter for an #arraymerge?

The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.


An now for a simple question: how do you set the delimiter for an #arraymerge ? Cavila 15:50, 27 November 2015 (UTC)

The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.

Use a break line as a delimiter

How do I do this? 86.141.179.229 (talk) 00:25, 4 January 2016 (UTC)

Should be possible with a regular expression as delimiter. Danwe (talk) 13:48, 10 July 2016 (UTC)

#arrayprint: Default delimiter?

Hi,

I'm using a combination of #arraydefine, #arraysort and #arrayprint to print a sorted list of page titles. I had to change the delimiter for #arraydefine and #arraysort from the default comma to a semicolon because some page titles contain commas. However, now I get semicolons in the output. I suspect that #arrayprint doesn't recognize them as delimiter. Could that be the case? Or am I missing something? Any pointers welcome.

TIA

Frank Nakohdo (talk) 15:31, 30 June 2017 (UTC)

You also need to specify the delimiter in #arrayprint: {{ #arraydefine: @array | this; is; an; array | ; }}{{ #arrayprint: @array | ; | ... }}.
On a semirelated note, for dealing with page titles, I'd recommend using some delimiter that you know can't appear in page titles; my usual go-to is an asterisk (with some care you might be able to use non-parenthesis brackets, though I've never tried (and yes, I realize that asterisks can appear in page titles, but in practice this is so rare that, unless your wiki has some specialized scope making it likely to happen, you can generally safely ignore the possibility)). ディノ千?!☎ Dinoguy1000 17:05, 30 June 2017 (UTC)
Good advice re choice of delimiter. Just to clarify: Nakohodo wanted to get rid of the semi-colons. To do so he should use {{ #arrayprint: @array || ... }}. Henryfunk (talk) 13:15, 23 November 2017 (UTC)
Many thanks for your quick reply and the pointer. The culprit was actually another semicolon I had added somewhere else in the template code. Using an asterisk makes the code more readable and should indeed be safer with page titles.
Speaking of SMW code readability, I've created a syntax highlighting scheme for Notepad++ to make life easier: https://github.com/nakohdo/NPP.SemanticMediaWiki Nakohdo (talk) 12:48, 6 July 2017 (UTC)

Tidy array?

I would like to make the following tiny, but I am not sure what will and will not break the functions.

{#arraydefine:array-list | {{{array}}}}}
{{#ifeq: {{#arraysize:array-list}} | 1 |
    {{{array}}} [[Category:{{{array}}} category]] |
    {{#arrayprint:array-list||@@@@|<nowiki/>
    * @@@@ [[Category:@@@@ category]]}}
    }}

I am getting an array, then checking to see how many items there are. If there is one item, just print the array as a normal parameter with a category. If there are two or more, print the array as a list with each item getting its own category. Right now it just looks bad. So, can someone please clean it up, and maybe offer better ways to write it? Thank you in advance! Lady Aleena (talk) 06:16, 19 November 2017 (UTC)

This answer perhaps goes in another direction than what you expected, but anyway: One change I would consider an improvement would be to change category names so they don't end in the string " category". It's redundant, and getting rid of it would in this case make your code 18 characters shorter :-) Henryfunk (talk) 12:20, 23 November 2017 (UTC)
The above use was as an example. I will put up the actual use if wanted. Lady Aleena (talk) 21:05, 23 November 2017 (UTC)
Ah, OK. I don't think the code in your example can be tidied up much. Do post it here, if you find a better solution. Henryfunk (talk) 09:12, 25 November 2017 (UTC)
Do you mean to categorize the page(s) this code will be used on? If not, make sure to link the categories by adding <code>:</code> at the beginning of the link.
I think that's about how I'd do this too (except using StringFunctions, see below). Really the only option for shortening the code that I can see would be to just always output the items as list items, even when there's only one. Of course, if someone else knows a way to shorten this, I'd also be interested in seeing. =)
If StringFunctions are enabled on your wiki, I would recommend the following code instead:
{{#if: {{#pos:{{{array}}} | , }} |
{{#arraydefine:array-list | {{{array}}} }}{{#arrayprint:array-list||@@@@|<nowiki/>
* @@@@ [[Category:@@@@ category]]}} |
{{{array}}} [[Category:{{{array}}} category]]
}}
This lets you avoid touching array functions at all unless you have more than one item to display. ディノ千?!☎ Dinoguy1000 17:15, 19 November 2017 (UTC)
I was just looking for a way to "tidy" the code, make it look good. Sort of like HTML Tidy. Thank you for stopping by! Lady Aleena (talk) 20:20, 19 November 2017 (UTC)
I just realized that I might need to change the delimiter. Names can have commas in them, so I am going to try to use a semicolon. Lady Aleena (talk) 20:37, 19 November 2017 (UTC)

Patterns

Is there a list of patterns? I was guessing with what I wrote in my previous question, using @@@@ as a pattern. However, I didn't see a link to a page with patterns. So, what are the patterns I can use? Lady Aleena (talk) 06:18, 19 November 2017 (UTC)

@@@@ is just an identifier, like "array-list", and it can be anything you want it to, as long as you're certain it won't appear in the input (since if it does, it will be replaced anywhere it appears, which is probably not what you want). Where I don't bother to name the identifier at all, I'm rather fond of using something like $x$ myself, though as far as being instantly recognizable goes, @@@@ works just as well (maybe a bit better, even). When I do name the identifier, I use $<name>, e.g. $el or $item. ディノ千?!☎ Dinoguy1000 17:21, 19 November 2017 (UTC)
That is great! I am very used to $name since I write a little bit of perl, and I am more comfortable with scalars using $ to start the name. Thank you! Lady Aleena (talk) 20:31, 19 November 2017 (UTC)

Works with MW 1.30.X ?

can someone say if this extension works with MW1.30.x? Yukii (talk) 22:00, 9 January 2018 (UTC)

It does, yes. ディノ千?!☎ Dinoguy1000 22:51, 9 January 2018 (UTC)
Unfortunately, at least version 491256a (last one from REL1_30) leads to problems with Mobile Frontend and the Minerva skin. The little arrows at the sections are not displayed, and the sections won't collapse again once they have been expanded once. I'll investigate that problem further. It's a pity that it isn't maintained, but perhaps someone has the skills to fix that bug, so if I can reproduce it I'll report it at Phabricator. CroMagnon (talk) 23:53, 12 April 2018 (UTC)
It works with the "master" branch (version 2166695). And it seems to be maintained still. *phew* CroMagnon (talk) 00:16, 13 April 2018 (UTC)
Why would this be "abandoned"? I have found it useful for my wiki. Not sure how to do some things otherwise. Are there suitable alternates if this truly is abandoned? ParallaxMonkey (talk) 00:04, 1 May 2018 (UTC)
It's not abandoned, it simply doesn't currently have a maintainer. The current version works with MediaWiki 1.30, and was released less than a year ago, though, so even without being actively maintained I expect it to continue working for a while. ディノ千?!☎ Dinoguy1000 06:30, 1 May 2018 (UTC)

Disallowed character combinations?

I think I just bumped into a weird character issue. I fed a string to an array using regex that allow for multiple delimiters (“ or ” = quotation marks). See code below. The body of the wiki page turned up blank. The problematic part of the string appeared to be the en dash – (not to be confused with - or the em dash) in combination with those delimiters. Removing it from the string solves it as does including the en dash among the delimiters.

{{#arraydefine:@somearray|Bla bla bla bla – oh well bla bla |/[“”]/}} {{#arrayprint:@somearray|;}}

Not sure if those quotation marks hold any special meaning in the syntax. Cavila 20:28, 3 September 2018 (UTC)

This sounds a lot like the issue I ran into in this topic four years ago. To be clear, are you saying that an en dash causes this, but an em dash does not? ディノ千?!☎ Dinoguy1000 05:20, 4 September 2018 (UTC)
No, I was trying to make unambiguously clear what character was causing trouble in this specific case. I just tested the same string with the em dash and the same thing happens. It does resemble the issue you ran into but I'm vague about the details. I should test if the problem can be worked around by resorting to a piped sequence of characters or character strings. Cavila 09:08, 4 September 2018 (UTC)

Future of the Arrays extension

Currently, the Arrays extension isn't actively maintained and poses some weird behavior, as well as questionable implementation in some cases. Considering this, we should collect all issues in one place and decide what should be done about that afterwards.

Additionally I'd like to ask: Does anyone still use this CompatibilityMode feature introduced seven years ago? There are people thinking about removing that functionality.

As I consider Flow even worse than wikitext for dicussions and really confusing as well, I would like to discuss this topic on Phabricator instead. This will tracking the issues identified there easier as well. However, if you have any trouble in setting up OAuth for Phabricator, feel free to speak ub in this thread as well. MGChecker (talk) 22:32, 4 September 2018 (UTC)

Basically there has not been any development to this extension since version 2 was released. That's why we still have the CompatibilityMode among other things. I you would like to take over maintaining it I am all for it including the place there discussions etc. should take place. [[kgh]] (talk) 09:06, 5 September 2018 (UTC)

#arraymap and #arraymaptemplate

These very useful parser functions are part of Page Forms. Couldn't/Shouldn't they be part of this extension?

I think there has been some discussion elsewhere about these parser functions but I can't remember where that was. AdSvS (talk) 08:36, 17 September 2018 (UTC)

I brought them up in phab:T203519. ディノ千?!☎ Dinoguy1000 10:18, 17 September 2018 (UTC)

Nonworking status 1.33.1

Extension:Arrays#Fatal bug


$egArraysExpansionEscapeTemplates is currently not initialized correctly, I think because of JSON code:

"config": {
		"ArraysCompatibilityMode": {
			"description": "Set to false by default since version 2.0.",
			"value": false
		},
		"ArraysExpansionEscapeTemplates": {
			"description": "Contains a key-value pair list of characters that should be replaced by a template or parser function call within array values included into an '#arrayprint'. By replacing these special characters before including the values into the string which is being expanded afterwards, array values can't distract the surrounding MW code. Otherwise the array values themselves would be parsed as well.\n\nThis has no effect in case $egArraysCompatibilityMode is set to false! If set to null, Arrays will jump to compatibility mode behavior on this, independently from $egArraysCompatibilityMode.",
			"value": [
				{
					"=": "{{=}}"
				},
				{
					"|": "{{!}}"
				},
				{
					"{{": "{{((}}"
				},
				{
					"}}": "{{))}}"
				}
			]
		}
	},

The PHP code produces an associative array that matches how escapeForExpansion uses it. escapeForExpansion produces a PHP diagnostic. Oddly though I didn't see it until I had a page name with an apostrophe in it. So it's possible escapeForExpansion isn't always utilized, without doing more analysis. Note, escapeForExpansion is the only consumer of $egArraysExpansionEscapeTemplates at least inside of ExtArrays.php.

$egArraysExpansionEscapeTemplates = [
	'='  => '{{=}}',
	'|'  => '{{!}}',
	'{{' => '{{((}}',
	'}}' => '{{))}}'
];

184.20.10.253 (talk) 15:20, 8 December 2019 (UTC)

Reported at T240111. ディノ千?!☎ Dinoguy1000 17:44, 9 December 2019 (UTC)
Thank you, looking at https://phabricator.wikimedia.org/T240111 I suggest explaining the extension.json code is the likely source of the error. I think it was probably written in haste, since extension.json is a new framework. This report here in Talk is a better resource I think. I tried to make the explanation in the Article easy to understand without tearing into details, so people can figure out a way to initialize the variable manually, since that's the only way to fix it (without modifying the JSON file or converting the JSON result into the expected result, whichever is correct. I don't know enough about the JSON setup to solve the problem.) 184.20.10.253 (talk) 19:54, 10 December 2019 (UTC)
Here (User talk:Ammarpad/Flow archive/Flow export#h-Please_take_responsibility_for_your_edit-2019-12-10T19:58:00.000Z) is attempt an editor made to hide the problem, they should be prepared to fix it them, or any case the problem is hidden now, so I hope someone is seeing it through. Someone should be interested in shepherding this new JSON system since someone saw fit to institute it. 184.20.10.253 (talk) 20:01, 10 December 2019 (UTC)

#arrayunique breaks #arraysearch

Consider the following example. The results in the top 12 and the bottom 12 should be identical, but after you run arrayunique, results from arraysearch are incorrect.

{{#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}}
#{{#arraysearch:abc|6|0|1|0}}
#{{#arraysearch:abc|7|0|1|0}}
#{{#arraysearch:abc|8|0|1|0}}
#{{#arraysearch:abc|9|0|1|0}}
#{{#arraysearch:abc|10|0|1|0}}
#{{#arraysearch:abc|11|0|1|0}}
#{{#arraysearch:abc|12|0|1|0}}
{{#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}}
#{{#arraysearch:abc|6|0|1|0}}
#{{#arraysearch:abc|7|0|1|0}}
#{{#arraysearch:abc|8|0|1|0}}
#{{#arraysearch:abc|9|0|1|0}}
#{{#arraysearch:abc|10|0|1|0}}
#{{#arraysearch:abc|11|0|1|0}}
#{{#arraysearch:abc|12|0|1|0}}

Results:

  1. 1
  2. 0
  3. 0
  4. 0
  5. 1
  6. 1
  7. 1
  8. 1
  9. 1
  10. 1
  11. 1
  12. 1
  1. 0
  2. 0
  3. 0
  4. 0
  5. 0
  6. 0
  7. 0
  8. 1
  9. 0
  10. 1
  11. 0
  12. 0 99.232.155.35 (talk) 09:04, 13 January 2020 (UTC)
This works correctly for me on a wiki running MediaWiki 1.31.1 and Ext:Arrays 2.1.0. What's your version of MediaWiki and Ext:Arrays? What do you see if you add an {{#arrayprint:abc}} after the #arrayunique? I see 10, 0, 8, 6, 7, 1, 9, 5, 12, 11. ディノ千?!☎ Dinoguy1000 09:37, 13 January 2020 (UTC)
A fresh install of MediaWiki 1.33.1 with Ext:Arrays 2.1.0. I get that same result (10, 0, 8, 6, 7, 1, 9, 5, 12, 11) from arrayprint when run after arrayunique. That's what kept throwing me trying to find this bug; after arrayunique, arrayprint is right, but the arraysearch results are completely wrong. 99.232.155.35 (talk) 21:46, 14 January 2020 (UTC)
A sample of the bug is live and visible at... ok, the system here refuses to let me post a link. Replace the spaces in the following with periods to get a url: wiki stratics com/index.php?title=User:BrianFreud/arrBug 99.232.155.35 (talk) 21:50, 14 January 2020 (UTC)
Okay, that's definitely a bug. Would you be willing to file a Phabricator ticket for this? I can do so if you can't or don't want to, just let me know.
For curiosity's sake, what happens if you define a new array like {{#arraydefine: def | {{ #arrayunique: abc }} }} and run the #arraysearch stuff on the new def array? What about if you define a third array like {{#arraydefine: ghi | 10, 0, 8, 6, 7, 1, 9, 5, 12, 11 }} and run the #arraysearches on it? ディノ千?!☎ Dinoguy1000 01:24, 15 January 2020 (UTC)
I've updated that same link with the three tests.
test1 fails; it is the arraydefine using only the arrayunique as input
test2 passes: it is the arraydefine using an arrayprint of the unique'd array
test3 passes (as we'd expect); it is the arraydefine using a manually entered copy of the unique'd array
Test 4 is a clean test with a new input array (same input as the un-unique'd array abc).
It passes. Looks like
```
{{#arraydefine:def|{{#arrayunique:def}}{{#arrayprint:def}}}}
```
is a working workaround, though it's clunky, and not what you'd expect to have to do.
I can enter a Phabricator ticket after work; don't have an account there to do it at the moment. 99.232.155.35 (talk) 01:45, 16 January 2020 (UTC)
That's the result I was expecting, to be honest.
Be sure to link the ticket here after you've created it! ディノ千?!☎ Dinoguy1000 06:04, 16 January 2020 (UTC)
Here you go: https://phabricator.wikimedia.org/T243031 Brianfreud (talk) 22:29, 16 January 2020 (UTC)

Arrays extension cannot parse certain numbers

The Arrays extension (version 2.2.0) cannot parse certain numbers (1, 2, 3, 0) under certain condition. These number changed to "Array" on output if a custom pattern is used.

Input: {{#arraydefine:places|1234567890; 2WE340; 654453562|;}} {{#arrayprint:places||@R|<nowiki/> * [[@R]]}}{{#arrayprint:places}} Output:

  • ArrayArrayArray456789Array
  • ArrayWEArray4Array
  • 65445Array56Array

1234567890, 2WE340, 654453562

https://phabricator.wikimedia.org/T245134 Acnetj (talk) 20:12, 13 February 2020 (UTC)

problems with MW 1.33.0 upgrade

I upgraded my database from MW 1.31 to 1.33, but I am having problems with the Arrays extension, specifically seeing strip markers (e.g. UNIQ--nowiki-ArrayArrayArrayArrayArrayArrayArray6-QINU) in the rendered page and the following messages:

Notice: Array to string conversion in extensions/Arrays/ExtArrays.php on line 1216

Warning: Cannot modify header information - headers already sent by (output started at /extensions/Arrays/ExtArrays.php:1216) in /includes/WebResponse.php on line 72

I'm not sure if this is related to other problems folks have posted. Any help appreciated! 108.7.72.249 (talk) 20:11, 25 March 2020 (UTC)

I'm not exactly sure what the problem here was; I reverted to an earlier version of the extension. 108.7.72.249 (talk) 13:41, 30 March 2020 (UTC)

arrayprint prints "Array"

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 (talk) 13:20, 22 May 2020 (UTC)

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 Kaffeeringe (talk) 20:31, 22 May 2020 (UTC)
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. ディノ千?!☎ Dinoguy1000 03:42, 23 May 2020 (UTC)
Thanks for pointing this out: https://phabricator.wikimedia.org/T245134
I solved this by setting legacy mode. Kaffeeringe (talk) 18:25, 23 May 2020 (UTC)
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... 99.232.155.35 (talk) 17:27, 25 May 2020 (UTC)
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. Becasita (talk) 22:09, 25 May 2020 (UTC)
The old docs in question are at Special:Diff/2888061#Differences compared to Arrays 2.0. ディノ千?!☎ Dinoguy1000 08:13, 26 May 2020 (UTC)
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}} }} ... }}
Brianfreud (talk) 01:25, 7 June 2020 (UTC)
Just an update that 0 is also affected, though 4 through 9 are ok to leave 'unprotected'. 99.232.155.35 (talk) 16:35, 20 September 2020 (UTC)

arrayprint prints "Array" (Part II)

Individual wikis can fix this by applying the changes listed here.

MW 1.34 + Arrays 2.2.0 (40737de)

Converted to 1.34 and seeing the "array prints "Array" issue [1] already documented.

I understand that it can be addressed one of two ways:

  1. Add $egArraysCompatibilityMode = true; in LocalSettings, or
  2. Update uses to conform to the new implementation standard.

I'm perfectly happy to update my wikitext to conform to the new array coding standard, but it's not clear to me what changes I need to make. The examples provided in Extension:Arrays hasn't changes that I can tell, only the way the extension processes the array values. Where's the in-wiki issue?

Please, what is the "in wiki" change I need to make to allow Arrays to handle my data as it previously did?

Thanks!

/Rich Revansx (talk) 12:51, 23 September 2020 (UTC)

[1] Extension talk:Arrays/archive 2/Flow export#h-arrayprint_prints_"Array"-2020-05-22T13:20:00.000Z Revansx (talk) 12:51, 23 September 2020 (UTC)

In the meantime I have put the extension into compatibility mode and indeed, all seems well. Revansx (talk) 13:18, 23 September 2020 (UTC)
No change should be required, this is purely an extension-side bug. See phab:T245134. ディノ千?!☎ Dinoguy1000 00:16, 24 September 2020 (UTC)
Is this already solved in MW 1.35 by chance? Revansx (talk) 00:45, 24 September 2020 (UTC)
I don't think so; my understanding is that this has to be fixed in the extension, not in MediaWiki (though I could be wrong). ディノ千?!☎ Dinoguy1000 14:09, 24 September 2020 (UTC)
You can fix this by editing the extension.json as shown here. MarkAHershberger(talk) 23:21, 7 December 2020 (UTC)
Thanks a lot! The provided patch works very well for me! Megajoule (talk) 09:10, 7 March 2021 (UTC)

Discrepancy in documentation?

In the arraysearch documentation, it states, "This function...returns an empty string when failed." However, in practice, I am seeing that it returns -1. Ammcgillivray (talk) 15:53, 27 October 2020 (UTC)

That is the case if compatibility mode is set (or you're using an old version of the extension), but it is not the current behaviour. Clump (talk) 16:02, 27 October 2020 (UTC)

issues making a list

The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.


I'm using this extension to build a template that takes a comma seperated list as an argument and prints it out as a bulleted list. It works for the first bullet, but the subsequent bullets are rendered as asterisks. Is it a bug?
{{#arraydefine:people|{{{1|}}}{{{people|}}}|,}}{{#arrayprint:people|<br />|@@@@|*{{has person|@@@@}} }}
I'm testing it with
{{has people|john smith, jason smith, sally smith}}
Which gives me something like this: https://www.crewsgenealogy.com/wiki/Test/array_problem

Is it a bug, or am I just missing something? The1gofer (talk) 16:49, 22 January 2021 (UTC)

You need the list syntax at the beginning of a line. Try the following code instead:

{{#arraydefine:people|{{{1|}}}{{{people|}}}|,}}{{#arrayprint:people|<br />|@@@@|
*{{has person|@@@@}} }}

If that doesn't fix it (I can't ever remember without testing myself), insert a <nowiki/> or <noinclude/> at the end of the first line:

{{#arraydefine:people|{{{1|}}}{{{people|}}}|,}}{{#arrayprint:people|<br />|@@@@|<noinclude/>
*{{has person|@@@@}} }}
ディノ千?!☎ Dinoguy1000 17:14, 22 January 2021 (UTC)
Thanks, the </nowiki> did the trick. The1gofer (talk) 18:01, 22 January 2021 (UTC)
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.

Is there a way to Pretty Print with 'or' instead of 'and'?

As the topic says. 160.3.176.211 (talk) 19:29, 23 April 2021 (UTC)

Unfortunately there isn't. Per ExtArrays.php line 188, the only valid values for the print option are list, which prints the input as a simple list, and pretty, which instead pretty prints it with the last two items separated by and (or presumably the interface language equivalent, depending on what exactly the $wgLang->listToText() function does).
If your wiki has Extension:Page Forms installed, you can instead use #arraymap, which allows you to change the delimiter used between the final two items in the array. ディノ千?!☎ Dinoguy1000 02:59, 24 April 2021 (UTC)

About the worrying warning at the top of the page

Is there a place to vote against the incompatibility of future MW developments with this very useful extension? :-/

Personally, I would rather scuttle Parsoid than Arrays and Variables. ;-) Megajoule (talk) 12:07, 26 April 2022 (UTC)

Let's focus this at Extension talk:Variables. MGChecker (talk) 16:29, 26 April 2022 (UTC)

{{#arraysort:}} does not honour proper numerical sorting

It seems that {{#arraysort:}} is more effective when letters are involved, but its duties with numbers leave a bit to be desired--and the extension's documentation has never made note of that. That much I found out after noon two days ago after setting up my first box-office chart for my geofictional realm in 8½ years. A title that was supposed to be #18 in rank...suddenly jumps into fourth place. (For context, the figures are 645247 [#3], 44189 [#4], 422290 [#5], 400261 [#6]... when they should be arranged as 645247, 422290, 400261...44189.)

It seems that PHP's natsort may be needed to remedy this in a future update of the extension. Until then, one must resort to this workaround if their site uses Page Forms (ad hoc example provided below):

{{#arraydefine:rand|{{#arraymap:4, 586, 46, 8, 79, 1031|,|*|{{#parsoid\0fragment:1}}*}}}}{{#arraysort:rand|desc}}{{#arrayprint:rand}}

To developers @Lidingpku: /@Baojie: /@Danwe: (And maybe recent talk-page guest @MGChecker: ) Just letting you three know of this apparent, hitherto-undiscovered upstream bug (in case you're still active on Wikimedia/MW.org). (Which may be enough for me to finally join WM Phabricator just so I can make a filing on this matter.)


Delayed by two days thanks to the technical difficulties described in Support desk Project:Support desk/Flow/2023/06#h-TypeError:_Cannot_read_properties_of_null_(reading_'match')-20230606212700. --Slgrandson (talk) 22:18, 8 June 2023 (UTC)

Array of available Namespaces

Hi! is it somehow possible to create an array out of an API-result? I want to get an array of all Namespaces and the furthest I got was with an API-query:

api.php?action=query&meta=siteinfo&siprop=namespaces

There is the option to use the extension Jsoner, but I think this is a bit of an overkill since I am not querying from an external site.. MarB-96 (talk) 08:49, 22 June 2023 (UTC)

duplicate in #arraysearcharraysearch

The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.


Hi all, in paragraph #arraysearcharraysearch, what is the use of first row of the example "Return index of first occurrence of a value" since it is duplicated at the head of the second row ? Thanks. --Christian 🇫🇷 FR (talk) 20:24, 20 November 2023 (UTC)

The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.

auto loop

The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.


in paragraph Configuration/$egArraysCompatibilityMode, remove link to sub page -> https://www.mediawiki.org/wiki/Special:MyLanguage/Extension:Arrays/Pre_2.0_Documentation#Differences_compared_to_Arrays_2.0 since it is itself a redirection to the current page itself -> #REDIRECT [[Extension:Arrays]] --Christian 🇫🇷 FR (talk) 19:41, 21 November 2023 (UTC)

The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.
Removed with this revision.

dead link in "6.4 Working with Extension:DynamicPageList" for

"DPL query. In the example" ->  http://semeb.com/dpldemo/index.php?title=DPL_Example_017

is no longer responding. Please can someone realign ? Thanks. --Christian 🇫🇷 FR (talk) 19:53, 21 November 2023 (UTC)