Page MenuHomePhabricator

[SRF] When used on images, "array" format fails
Closed, ResolvedPublic

Description

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:

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:

Also, #arraymap from Semantic Forms will also fail:

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=listsep=,link=none}}

}}

The #arrayprint then succeeds:

The #arraymap also succeeds:

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


Version: unspecified
Severity: major

Details

Reference
bz32977
TitleReferenceAuthorSource BranchDest Branch
Refactor styles & improve CTA link/buttonrepos/sre/miscweb/wikiworkshop!14daniadd-ray-btnmaster
Set build stage in blubber pipelinerepos/sre/miscweb/wikiworkshop!13danihugo-cimaster
Add "Call for hall" subpagerepos/sre/miscweb/wikiworkshop!12danikinneretmaster
Make design improvementsrepos/sre/miscweb/wikiworkshop!11danidesign-improvementsmaster
Set up static site generatorrepos/sre/miscweb/wikiworkshop!10danisetup-hugomaster
Update 2024 editionrepos/sre/miscweb/wikiworkshop!8daniwikiworkshop2024-4master
Create "call-for-papers" subpage and other requests by Kinneretrepos/sre/miscweb/wikiworkshop!6daniwikiworkshop2024-3master
Ensure page have some empty space at the bottomrepos/sre/miscweb/wikiworkshop!5danifooter-ensure-paddingmaster
Update content and implement "black with underline" stylerepos/sre/miscweb/wikiworkshop!4daniwikiworkshop2024-2master
Prepare site for Wikiworkshop 2024repos/sre/miscweb/wikiworkshop!2daniwikiworkshop2024master
Customize query in GitLab

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 12:01 AM
bzimport set Reference to bz32977.

Re-assigning to DanWe - seems like the correct person for this one.

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.

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.

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 "| ?" ).

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.

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

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.

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

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.

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

(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.

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.