Closed jongfeli closed 2 months ago
Okay, after some debugging I found "the problem".
In DataTabels.php I moved $result = $this->getResultJson( $res, $outputmode );
to be above and before // @TODO use only one between printouts and printrequests
$formattedOptions = $this->formatOptions( $datatablesOptions );
$result = $this->getResultJson( $res, $outputmode );
// @TODO use only one between printouts and printrequests
$resultArray = $res->toArray();
$printrequests = $resultArray['printrequests'];
$this->useAjax = $this->query->getOption( 'useAjax' );
I am not sure if this is a correct fix or that it will cause other problems but now at least the outputted table is complete again.
ping @krabina @thomas-topway-it
@jongfeli can you please try with the latest version of Datatables ? https://github.com/semanticMediaWiki/SemanticResultFormats --- we have merged it right 2 days ago. Thanks a lot
Hi @thomas-topway-it I downloaded the code but I still need to move $result = $this->getResultJson( $res, $outputmode );
to get it to work.
ok, thank you, I will review it soon
I run into the same problem, and looked into the code. QueryResult::toArray
moves the QueryResult
iterator cursor to the last position, and we should call QueryResult::reset
at the to of getResultJson
and then loop the QueryResult
iterator.
Sorry, that was not correct. I looked into the code again, and wrote a patch SemanticMediaWiki/SemanticMediaWiki/pull/5623 , that should fix the problem...
hello Iroaki, @hkwi I wanted to post that the idea about resetting the iterator was a great hint (anyway). So do you confirm that the provided patch fixes the issue, and that is not related to Datatables ?
With noajax=true
option, I confirmed the patch fixes the issue, that CHAIN property drops values.
Datatables plugin scans the QueryResult twice, while many plugins scan once. In the first scan, results are all filled, but in the second scan, cache is broken and values are lost. First scan will be triggerd by $res->toArray()
and second is getResultJson()
. We only capture the result part of toArray()
output, so putting getResultJson()
before toArray()
shall be a good work-around anyway, IMHO.
@thomas-topway-it can you test the patch in our FINA wiki, so we can confirm everything is still working?
I have just came across this issue in my wiki, too.
@jongfeli please test the master version, it works for me now.
"mediawiki/semantic-result-formats": "dev-master",
@jaideraf, yes it is working just fine, thank you.
Setup
Issue
Anything above SRF 4.0.2 will break to following query when the format=datatables is used. When there are multiple results it will show all the SubobjectProperties but only one or none of the ParentProperties:
Steps to reproduce Made an example in the SMW sandbox but it is running SRF 4.0.2 so it is still working. See: https://sandbox.semantic-mediawiki.net/wiki/Subobject_In_Datatables
The result with 4.0.2:![Datatables_Result_SRF_4 0 2](https://github.com/SemanticMediaWiki/SemanticResultFormats/assets/6680027/fdd4af66-c835-4833-b99e-e2257d0b6389)
The result with SRF 4.2.1 would look something like this:![Datatables_Result_SRF_4 2 1](https://github.com/SemanticMediaWiki/SemanticResultFormats/assets/6680027/31c462b4-5ed8-410d-8f22-b5f723abfd25)
Best regards,
Felipe.