Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParentProperties not shown with format=datatables #825

Closed
jongfeli opened this issue Mar 28, 2024 · 12 comments
Closed

ParentProperties not shown with format=datatables #825

jongfeli opened this issue Mar 28, 2024 · 12 comments
Labels

Comments

@jongfeli
Copy link

jongfeli commented Mar 28, 2024

Setup

  • MW version: 1.39.5
  • DB (MySQL etc.): 11.3.2-MariaDB
  • PHP version: 8.1.24 (apache2handler)
  • SMW version: 4.1.3
  • SRF version: 4.2.1
  • Browsers and versions (if applicable): Firefox 124.0.1 (64-bit)

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:

{{#ask: [[YourSubobjectProperty1::SubobjectProperty]]
 |?-has subobject.YourParentProperty1
 |?-has subobject.YourParentProperty2
 |?YourSubobjectProperty2
 |format=datatables
}}

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

The result with SRF 4.2.1 would look something like this:
Datatables_Result_SRF_4 2 1

Best regards,

Felipe.

@jongfeli
Copy link
Author

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.

@gesinn-it-gea
Copy link
Member

ping @krabina @thomas-topway-it

@thomas-topway-it
Copy link
Contributor

@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

@jongfeli
Copy link
Author

jongfeli commented Apr 2, 2024

Hi @thomas-topway-it I downloaded the code but I still need to move $result = $this->getResultJson( $res, $outputmode ); to get it to work.

@thomas-topway-it
Copy link
Contributor

ok, thank you, I will review it soon

@hkwi
Copy link

hkwi commented Apr 11, 2024

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

hkwi added a commit to hkwi/SemanticMediaWiki that referenced this issue Apr 11, 2024
There is a case that key from makeCacheKey is same, but
fingerprint from subjects are different, typically with
subobject property path resolution.
SemanticMediaWiki/SemanticResultFormats#825

Using same PrefetchCache, if there comes new prefetch call
with same key but different fingerprint, then the old cache
will be replaced with the new result.
I think we should merge the result here.
@krabina krabina added the bug label Apr 17, 2024
@thomas-topway-it
Copy link
Contributor

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 ?

@hkwi
Copy link

hkwi commented Apr 21, 2024

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.

@krabina
Copy link
Contributor

krabina commented Apr 22, 2024

@thomas-topway-it can you test the patch in our FINA wiki, so we can confirm everything is still working?

@jaideraf
Copy link
Member

jaideraf commented May 3, 2024

I have just came across this issue in my wiki, too.

@jaideraf
Copy link
Member

jaideraf commented May 7, 2024

@jongfeli please test the master version, it works for me now.

"mediawiki/semantic-result-formats": "dev-master",

@krabina krabina closed this as completed May 7, 2024
@jongfeli
Copy link
Author

jongfeli commented May 8, 2024

@jaideraf, yes it is working just fine, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants