From e0ed0a39171a4cfb9b14afd31b27e1c39a051c5a Mon Sep 17 00:00:00 2001 From: Simon Stier <52674635+simontaurus@users.noreply.github.com> Date: Tue, 12 Nov 2024 07:30:50 +0100 Subject: [PATCH 1/2] handle SPARQLStore backends fixes #827 See also https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/5748 --- formats/datatables/SearchPanes.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/formats/datatables/SearchPanes.php b/formats/datatables/SearchPanes.php index eddaabcf3..71e20eb97 100644 --- a/formats/datatables/SearchPanes.php +++ b/formats/datatables/SearchPanes.php @@ -48,6 +48,16 @@ public function __construct( $datatables ) { * @return array */ public function getSearchPanes( $printRequests, $searchPanesOptions ) { + if ( $this->datatables->store instanceof \SMW\SPARQLStore\SPARQLStore ) { + // we got a SPARQLStore, which is not subclass of SQLStore + // dirty hack to access the private member baseStore, which is an instance of SQLStore + // this can be simplified once SPARQLStore is refactored to make this member public + // see https://github.com/SemanticMediaWiki/SemanticResultFormats/issues/827 + $closure = \Closure::bind(function &(\SMW\SPARQLStore\SPARQLStore $class) { + return $class->baseStore; + }, null, \SMW\SPARQLStore\SPARQLStore::class); + $this->datatables->store = &$closure($this->datatables->store); + } $this->queryEngineFactory = new QueryEngineFactory( $this->datatables->store ); $this->connection = $this->datatables->store->getConnection( 'mw.db.queryengine' ); $this->queryFactory = new QueryFactory(); From 84f94833831191ec527ee48a5890f76647cd274e Mon Sep 17 00:00:00 2001 From: Simon Stier <52674635+simontaurus@users.noreply.github.com> Date: Tue, 12 Nov 2024 07:38:43 +0100 Subject: [PATCH 2/2] fix code styling --- formats/datatables/SearchPanes.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/formats/datatables/SearchPanes.php b/formats/datatables/SearchPanes.php index 71e20eb97..da25ad636 100644 --- a/formats/datatables/SearchPanes.php +++ b/formats/datatables/SearchPanes.php @@ -53,10 +53,10 @@ public function getSearchPanes( $printRequests, $searchPanesOptions ) { // dirty hack to access the private member baseStore, which is an instance of SQLStore // this can be simplified once SPARQLStore is refactored to make this member public // see https://github.com/SemanticMediaWiki/SemanticResultFormats/issues/827 - $closure = \Closure::bind(function &(\SMW\SPARQLStore\SPARQLStore $class) { + $closure = \Closure::bind( function &( \SMW\SPARQLStore\SPARQLStore $class ) { return $class->baseStore; - }, null, \SMW\SPARQLStore\SPARQLStore::class); - $this->datatables->store = &$closure($this->datatables->store); + }, null, \SMW\SPARQLStore\SPARQLStore::class ); + $this->datatables->store = &$closure( $this->datatables->store ); } $this->queryEngineFactory = new QueryEngineFactory( $this->datatables->store ); $this->connection = $this->datatables->store->getConnection( 'mw.db.queryengine' );