Page MenuHomePhabricator

parser function #set / settting multiple values for the same property
Closed, ResolvedPublic

Description

Author: mitchell_neill

Description:
Hi.

I have a string property that holds multiple values. If I do:

{{#set:Access Codes={{{Codes|}}}}}

The Access Codes property does not get set. Example {{{Codes|}}} string:
Parents/Carers required to stay, Accessible Toilet, Siblings Welcome, Wheelchair Access

This used to work with SMW 1.5.6 so it looks like this got broken in SMW
1.18. It's a real pain as it looks like you cannot silently set using
arraymap using:
{{#arraymap:{{{Codes|}}}|,|xx|[[Access Codes::xx]]|}}

Cheers
Neill.


Version: unspecified
Severity: enhancement

Details

Reference
bz36309

Related Objects

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 12:28 AM
bzimport set Reference to bz36309.
bzimport added a subscriber: Unknown Object (MLST).

Just to clarify, since there is no SMW 1.18.: You are using MW 1.18.x with SMW 1.7.1 or SMW 1.8.alpha?

mitchell_neill wrote:

Hi.

I am using SMW 1.8.alpha with MW 1.17.3

mitchell_neill wrote:

I just upgraded another older wiki to SMW 1.18alpha and a lot of #sets then failed.

So it looks like this is not just limited to multiple values. It seems to me that #set can only cope with 0-9 a-Z characters.

Neill, any idea when it broke? There where some significant changes in 1.6 that might have caused this.

mitchell_neill wrote:

I don't think I ever used 1.6. The 3 sites I recently upgraded were all 1.5.6.

It certainly doesn't cope well any more with things like:
{{#set:Name Link=[[{{PAGENAME}}|{{{Page_Title|}}}]]}}
This example works fine with 1.5.6.

I suspect the multiple values have stopped working because it can't cope with comma's now.

Let me know if there is anything you'd like me to do help to narrow this down :)

Cheers
Neill.

(In reply to comment #0)

Hi.

I have a string property that holds multiple values. If I do:

{{#set:Access Codes={{{Codes|}}}}}

The Access Codes property does not get set. Example {{{Codes|}}} string:
Parents/Carers required to stay, Accessible Toilet, Siblings Welcome,
Wheelchair Access

This used to work with SMW 1.5.6 so it looks like this got broken in SMW
1.18. It's a real pain as it looks like you cannot silently set using
arraymap using:
{{#arraymap:{{{Codes|}}}|,|xx|[[Access Codes::xx]]|}}

Cheers
Neill.

Did you try to use #set inside an #arraymap? Like this:

{{#arraymap:{{{Codes|}}}|,|xx|{{#set:Access Codes=xx}}}}

mitchell_neill wrote:

Thanks for the tip!

Yes, that seems to work except when the property has certain non a-Z 0-9 characters e.g. , ' / etc

mitchell_neill wrote:

Hi.

Just tested with SW 1.8 b2 and the problem is still present.

Another example:
{{#set:Age Values=1,2,3,4,5,6,7,8,9,10}} does not work where Age Values is a string property.

Is this ever going to get fixed? #set really shouldn't have this serious limitation.

Thanks.

What do you expect to be the outcome of this? The expected outcome is that "Age Values" is assigned a value "1,2,3,4,5,6,7,8,9,10". Does documentation suggest something else?

leo_wallentin wrote:

Maybe there is some confusion here with the #set_internal parser function of Semantic Internal Objects, which actually allows for something similar? Just a guess.

How about making this bug into a feature request for implementing something like {{#set:Age Values#list=1,2,3,4,5,6,7,8,9,10}}

mitchell_neill wrote:

Hi.

It's not a feature request, it's a bug I think. #set on a string property should accept any valid string character. This is not just about the comma character, #set also does not work with lots of other non a-Z 0-9 chars.

You suggestion on extending #set to support lists is a very good one, but not the complete solution to this problem.

Thanks.

mitchell_neill wrote:

HI.

Sorry, just to re-iterate one other point. This used to work with SMW 1.5.6. So this not some fundamental problem.

Cheers.

leo_wallentin wrote:

I'm trying to reproduce this on Scratchpad (SMW 1.8 beta 2), but for me set seems to be working with any characters in the string:

http://scratchpad.referata.com/wiki/User:Rotsee/set_test

Unknown Object (User) added a comment.Nov 7 2012, 1:34 PM

Has been verified to be working with SMW 1.8.

Please feel free to reopen this bug again if it applies to SMW 1.8+.

mitchell_neill wrote:

Great that #set is coping with all chars :)

I've tried an example similar to the original report.

http://scratchpad.referata.com/wiki/User:Rotsee/set_test

Has age has a number of allowed values:

The allowed values for this property are:

  • [[Allows value::All]]
  • [[Allows value::1]]
  • [[Allows value::2]]
  • [[Allows value::3]]
  • [[Allows value::4]]
  • [[Allows value::5]]
  • [[Allows value::6]]
  • [[Allows value::7]]
  • [[Allows value::8]]
  • [[Allows value::9]]
  • [[Allows value::10]]

{{#set:Has age=1,2,3,4,5,6,7,8,9,10}} does not work. This is an example of the original reason the bug was opened. #set no longer assigns multiple values. This works on SMW 1.5.6, but perhaps that was more luck that design (and I mean this in the nicest way!) In fact, stepping back here and thinking about it, perhaps it should not have worked. A string is a string.

Looking back at the evolution of this bug, I think actually that Leonard's suggestion of a syntax extension may be the best solution here e.g.

{{#set:Age value#list=1,2,3,4,5,6,7,8,9,10}}.

In this way the ability to put any char into the #set is covered off and lists of values are also explicitly covered off. No grey areas!

leo_wallentin wrote:

Well, that SHOULD not work, as "1,2,3,4,5,6,7,8,9,10" is not an allowed value. If it ever worked, I guess it must have been a bug back then, that got fixed since?

This, however, should probably do what you want: {{#set:Has age=1|Has age=2|Has age=3...}}. Or, as suggested above, you could use the arraymap function!

leo_wallentin wrote:

I am changing this bug into an enhancement request, for introducing a something like the SIO style {{#set:Property#list=...}} mentioned above.

I have added a note about how to set multiple values to the same property to the documentation.

http://semantic-mediawiki.org/wiki/Help:Setting_values

Unknown Object (User) added a comment.Nov 8 2012, 6:10 AM

[1] introduces #list to enable multiple values separated by a comma for the same property.

Review is pending and if merged will be deployed with SMW 1.9.

[1] https://gerrit.wikimedia.org/r/#/c/32347/

mitchell_neill wrote:

Excellent news! I think will be a very useful addition.

Thanks for everyone's input.

This is a goody I guess. :) As soon as this bug gets closed I will document this on smw.

Unknown Object (User) added a comment.Nov 13 2012, 4:34 PM

Change [1] has been merged with SMW 1.9+ (This change is not valid for SMW 1.8). The unit test is available at [2].

The multi value identifier |+sep= and supports:

{{#set:

has test 0=Example 1,Example 2,Example 3,Example 4+sep=,
has test 1=Example 1;Example 2;Example 3;Example 4+sep=;
has test 2=Single examples
has test 3=Example 1Example 2Example 3Example 4
has test 1=Example 1,Example 2,Example 3,Example 4+sep=

}}

If +sep= is left empty, the default is set to ",".

[1] https://gerrit.wikimedia.org/r/#/c/32347/

[2] https://gerrit.wikimedia.org/r/#/c/32347/6/tests/phpunit/includes/parserhooks/ParserParameterTest.php

mitchell_neill wrote:

Excellent job. Thanks a lot, that is really useful functionality :)