Last modified: 2012-11-15 19:35:06 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T38309, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 36309 - parser function #set / settting multiple values for the same property
parser function #set / settting multiple values for the same property
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Semantic MediaWiki (Other open bugs)
unspecified
All All
: Normal enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks: 41842
  Show dependency treegraph
 
Reported: 2012-04-27 20:07 UTC by Neill Mitchell
Modified: 2012-11-15 19:35 UTC (History)
6 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Neill Mitchell 2012-04-27 20:07:27 UTC
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.
Comment 1 [[kgh]] 2012-04-27 20:20:05 UTC
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?
Comment 2 Neill Mitchell 2012-05-07 14:08:59 UTC
Hi.

I am using SMW 1.8.alpha with MW 1.17.3
Comment 3 Neill Mitchell 2012-07-03 10:23:50 UTC
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.
Comment 4 Jeroen De Dauw 2012-07-03 11:15:57 UTC
Neill, any idea when it broke? There where some significant changes in 1.6 that might have caused this.
Comment 5 Neill Mitchell 2012-07-03 12:45:05 UTC
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.
Comment 6 Jaider Andrade Ferreira 2012-08-01 12:39:40 UTC
(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}}}}
Comment 7 Neill Mitchell 2012-08-02 08:43:20 UTC
Thanks for the tip!

Yes, that seems to work except when the property has certain non a-Z 0-9 characters e.g. , ' / etc
Comment 8 Neill Mitchell 2012-10-24 10:14:03 UTC
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.
Comment 9 Markus Krötzsch 2012-10-25 08:28:05 UTC
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?
Comment 10 Leonard Wallentin 2012-10-25 09:21:06 UTC
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}}
Comment 11 Neill Mitchell 2012-10-26 09:40:44 UTC
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.
Comment 12 Neill Mitchell 2012-10-26 09:50:29 UTC
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.
Comment 13 Leonard Wallentin 2012-10-26 10:11:05 UTC
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
Comment 14 MWJames 2012-11-07 13:34:07 UTC
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+.
Comment 15 Neill Mitchell 2012-11-07 20:09:22 UTC
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!
Comment 16 Leonard Wallentin 2012-11-07 22:18:22 UTC
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!
Comment 17 Leonard Wallentin 2012-11-07 22:46:49 UTC
I am changing this bug into an enhancement request, for introducing a something like the SIO style {{#set:Property#list=...}} mentioned above.
Comment 18 [[kgh]] 2012-11-07 23:37:14 UTC
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
Comment 19 MWJames 2012-11-08 06:10:48 UTC
[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/
Comment 20 Neill Mitchell 2012-11-08 17:17:50 UTC
Excellent news! I think will be a very useful addition.

Thanks for everyone's input.
Comment 21 [[kgh]] 2012-11-08 17:21:41 UTC
This is a goody I guess. :) As soon as this bug gets closed I will document this on smw.
Comment 22 MWJames 2012-11-13 16:34:29 UTC
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 1|Example 2|Example 3|Example 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
Comment 23 Neill Mitchell 2012-11-13 17:32:23 UTC
Excellent job. Thanks a lot, that is really useful functionality :)

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links