Last modified: 2012-01-10 20:28:28 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 T34977, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 32977 - [SRF] When used on images, "array" format fails
[SRF] When used on images, "array" format fails
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
SemanticResultFormats (Other open bugs)
unspecified
All All
: Unprioritized major (vote)
: ---
Assigned To: Daniel A. R. Werner
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-12-12 05:38 UTC by badon
Modified: 2012-01-10 20:28 UTC (History)
2 users (show)

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


Attachments

Description badon 2011-12-12 05:38:49 UTC
This will display images instead of silently storing them in an array:

{{#ask: [[Category:Images]] | ? | format=array | name=image array}}

Using #arrayprint from the Arrays extension will then fail:

{{#arrayprint: image array | <br /> | VariableValue | [[VariableValue|180px]] }}

Using link=none on the #ask query will still non-silently produce a File:pagename list:

{{#ask: [[Category:Images]] | ? | format=array | name=image array | link=none}}

Once again, using #arrayprint from the Arrays extension will then fail:

{{#arrayprint: image array | <br /> | VariableValue | [[VariableValue|180px]] }}

Also, #arraymap from Semantic Forms will also fail:

{{#arraymap:{{#arrayprint: image array}}|,|VariableValue|[[VariableValue|180px]]|\n\n}}

With two different extensions failing to make use of the data that the SMW "array" format is providing, in two different ways, it appears that the array format is non-functional when dealing with files and/or images.

The workaround is to use the "list" format, with the "sep=," parameter to manually construct a data set:

{{#arraydefine: image array
| {{#ask: [[Category:Images]] | ? | format=list | sep=, | link=none}}
}}

The #arrayprint then succeeds:

{{#arrayprint: image array | <br /> | VariableValue | [[VariableValue|180px]] }}

The #arraymap also succeeds:

{{#arraymap:{{#arrayprint: image array}}|,|VariableValue|[[VariableValue|180px]]|\n\n}}

I marked this as major instead of critical because although the array feature of SMW's Semantic Result Formats is non-functional with images (I didn't test other data types), the problem can be worked around as described. Here's the relevant documentation. Note that part of it is incomplete, and does not describe some of the things I did in my examples above:

http://semantic-mediawiki.org/wiki/Help:Array_format
http://www.mediawiki.org/wiki/Extension:Semantic_Result_Formats
Comment 1 Yaron Koren 2011-12-13 04:11:21 UTC
Re-assigning to DanWe - seems like the correct person for this one.
Comment 2 Daniel A. R. Werner 2011-12-13 13:28:57 UTC
Assuming you just have image sites in that category whose titles you want to get, you might want to use

{{#ask: [[Category:Images]] | format=array | name=image array}}

instead. (without the '...| ? ...' part ). This works perfectly for me then, at least with format=array and #arrayprint. I didn't try #arraymap since I have nothing to do with that.
If it is something more complicated you are trying to do here, like having some image type attributes, then I need more information about that.

Please give more information. Which version of MW, SMW and especially Arrays and Semantic Result Formats do you use?

Semantic Result Formats supports array format for some time but this wasn't intended, back than it was more experimental. r103909 is stable though. So it was included before but not within default formats and not publicly announced or anything. So, please make sure you use the current version.
You should use it with the current Arrays extension, either trunk or Arrays 2.0rc2

About the documentation, if you tell me what about the Array format documentation is incomplete, I would be happy to update it.
By the way, for 'array' format, 'link' is set to 'none' by default.
Comment 3 badon 2011-12-14 05:13:48 UTC
The examples above were tested using MW 1.17, SMW 1.6, and SRF 1.6. I tried my examples on SRF 1.6.2, and now the workaround fails too. I followed your suggestion and removed the "| ?" portion of the query, and there was no change in the results.

Here's a demo, login with Demo/test:

http://www.coincompendium.com/wiki/index.php/Sandbox/Bug_32977

If I notice any other problems, I may need to downgrade SRF, but so far it is at SRF 1.6.2.
Comment 4 Daniel A. R. Werner 2011-12-14 16:03:25 UTC
Alright, that's outdated then. The array format was strongly improved in SRF 1.7, so you have to wait for that or use the current trunk version where it works (without the "| ?" ).
Comment 5 badon 2011-12-14 20:05:47 UTC
OK, I'll take your word for it and test SRF 1.7 when it comes out. I marked this as verified/worksforme until the new version is released.
Comment 6 badon 2012-01-07 03:17:51 UTC
This does not work, and seems to have regressed a little more:

http://www.coincompendium.com/w/index.php/Sandbox/Bug_32977

In addition, the list format has been further broken with additional parentheses, so there is no longer any workaround available that I know of:

https://bugzilla.wikimedia.org/show_bug.cgi?id=32863
Comment 7 Daniel A. R. Werner 2012-01-07 11:39:56 UTC
Sorry, but there was another bug in the final 1.7 release which was just fixed in r107922
This did set the default separator which should be ", " to some very weird value.
Please try updating to r107922+ or simply try setting $srfgArraySep = ", " in your localsettings. This might be the cause for your new problems. I can't see the "coincompendium" page, seems to be non-public.
Comment 8 badon 2012-01-09 00:45:57 UTC
No need to apologize, bugs happen, and I find them :) 

I tested r107922, but SMW 1.7 either mangles image data with superfluous parentheses that can't be reliably removed, or it forcibly presents the data as displayed images without giving access to the raw data for further processing, so I can't distinguish for sure what SRF is doing to images in its array format:

https://bugzilla.wikimedia.org/show_bug.cgi?id=30002

https://bugzilla.wikimedia.org/show_bug.cgi?id=30494

https://bugzilla.wikimedia.org/show_bug.cgi?id=32863

The login info for the coincompendium site is in comment 3. You can login with the credentials: Demo/test

You can see the original demo for this bug here:

http://www.coincompendium.com/w/index.php/Sandbox/Bug_32977

and some other temporary fiddling around here:

http://www.coincompendium.com/w/index.php/Sandbox
Comment 9 badon 2012-01-09 01:00:55 UTC
Actually, it looks like there was an undocumented change in the output format of query results. I'm marking this fixed, while I do more testing.
Comment 10 badon 2012-01-09 01:17:14 UTC
Here's some info about the change that I posted to the mailing list, for anybody that runs across this bug report while looking for answers:

http://wikimedia.7.n6.nabble.com/Semantic-Result-Formats-1-7-released-td2799845.html#a3504612
Comment 11 Daniel A. R. Werner 2012-01-10 17:48:38 UTC
(In reply to comment #8)
> I tested r107922, but SMW 1.7 either mangles image data with superfluous
> parentheses that can't be reliably removed, or it forcibly presents the data as
> displayed images without giving access to the raw data for further processing

That's exactly why I created the array format, because the list format output uses "(", ")" and "," in a way which makes it quite impossible to datermine whether they are part of the data value or of the output format.
Using Array format with some more complex separators should by default always print you the raw data values (unless you change the "link" parameter or use "headers=show").

Honestly, I don't care about the "list" format anymore, I have used it before with some very complex parser function to convert its result to something similar as array format. Now I consider "list" format just for data printout as for direct data presentation but not for usage within templates which want to display data differently. Using "Array" Extension and format works perfectly for that and if it's not enough you might want to think about writing some special result format adjusted for your needs.
Comment 12 badon 2012-01-10 20:28:28 UTC
I'm also very happy with the Array extension. I've started using it for everything now, instead of the list format. I consider it one of the most important extensions available for advanced usage of MediaWiki:

http://www.mediawiki.org/wiki/User:Badon#Advanced_MediaWiki_programming_toolkit

Further testing of the array format has not revealed any issues, so while I continue to test (as always), I still consider this bug resolved as FIXED.

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


Navigation
Links