Form fails on SMW 1.8 #ask
Closed, DeclinedPublic


A project form uses {{#ask: [[Category:Project]] |?Project number | format=max }} to determine the current highest project number.

The form fails - a white screen appears after a long while instead of the form to appear - when the project is edited with form.

The 'ask' showed above seems to be the cause of the problem, since the form shows promptly when it is removed from the form definition. Also the problem doesn't occur with SMW 1.7.1 in combination with SF 2.5.1.

The problem occurs with SMW 1.8 beta 2. Other versions are: MW 1.19.2, SF 2.5.1, SRF 1.8 rc2.

Version: unspecified
Severity: normal


AdSvS created this task.Nov 22 2012, 7:08 AM

Please try the following query instead:

{{#ask: [[Category:Project]]

?Project number=
sort=Project number


and compare its result with the result of your original query (if you can get it at all). Please let us know if this works.

Ok I did what you suggested and did some additional research. The interesting results I think are:

{{{field|Project number|default= {{#expr: {{#ask: [[Category:Project]]

?Project number
}} + 1}}


shows '{{#expr: {{#ask:' in the project number field when creating a new project (NOK) and
works well when editing a project with the form (OK).

The original statement: {{{field|Project number|default= {{#expr: {{#ask: [[Category:Project]] | ?Project number | format=max }} + 1}} }}}
which is exactly the same, only the whole 'field' statement on one line,

shows the correct (next) project number when creating a new project (OK) and
causes the form to fail (white screen after long while) when editing the project (NOK)

If the query that I suggested works for you, it is highly recommended to use this query instead of format=max everywhere. Similarly for format min (but change the order to ASC there). If you want to do math with the result, you should also specify that you do not want any formatting by adding a #-:

{{#ask: [[Category:Project]]

?Project number#-=
sort=Project number


The max format should be avoided whenever possible. It is very resource intensive (possibly retrieving thousands of results to find one number) and may still lead to wrong results (if there are too many matches).

The other problem you mention here seem to be related to {{{field}}} but not to SMW. I don't see why there should be a connection to SMW 1.8, but maybe there were some small output changes in #ask that your code is somehow sensitive to. I am reassigning this bug to SF now.

The query you suggested shows the same results - with the addition of 'search label=' or the result includes ...further results, which is hard to use in calculations.

This means the creation of a new project works fine and editing fails.

AdSvS added a comment.Dec 2 2012, 9:01 AM

My hosting provider migrated to php 5.3.19 and the problems don't appear anymore.
It seems that the problem is related to (very) old php versions and new versions of the extensions.
Since php 5.2 is not supported anymore in the next version of SMW 'unconfirmed' seems appropriate to me.

Marking as Invalid for now; only one person had the problem and it worked for him

Sounds more like WORKSFORME then... :)

AdSvS added a comment.Dec 2 2012, 3:39 PM

You guys can do things with the status that wouldn't even have dreamed of ;-)

Restricted Application added a subscriber: StudiesWorld. · View Herald TranscriptJan 28 2016, 6:10 PM

Add Comment