Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions formats/datatables/QuerySegmentListProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

use RuntimeException;
use SMW\MediaWiki\Database;
use SMW\SQLStore\QueryEngine\QuerySegment;
use SMW\SQLStore\TableBuilder\TemporaryTableBuilder;
use SMWQuery as Query;
use SMW\SQLStore\QueryEngine\QuerySegment;

class QuerySegmentListProcessor {
/* @var array */
Expand Down Expand Up @@ -60,7 +60,7 @@ class QuerySegmentListProcessor {
* @param TemporaryTableBuilder $temporaryTableBuilder
* @param HierarchyTempTableBuilder $hierarchyTempTableBuilder
*/
public function __construct( $connection, TemporaryTableBuilder $temporaryTableBuilder, $hierarchyTempTableBuilder ) {
public function __construct( $connection, TemporaryTableBuilder $temporaryTableBuilder, $hierarchyTempTableBuilder ) {
$this->connection = $connection;
$this->temporaryTableBuilder = $temporaryTableBuilder;
$this->hierarchyTempTableBuilder = $hierarchyTempTableBuilder;
Expand All @@ -87,7 +87,7 @@ public function setQuerySegmentList( &$querySegmentList ) {
/**
* @since 2.2
*
* @param integer
* @param integer $queryMode
*/
public function setQueryMode( $queryMode ) {
$this->queryMode = $queryMode;
Expand Down Expand Up @@ -132,8 +132,6 @@ private function segment( QuerySegment &$query ) {
case QuerySegment::Q_VALUE:
break; // nothing to do
}


}

/**
Expand All @@ -158,20 +156,19 @@ private function table( QuerySegment &$query ) {
$alias = 'nested' . $subQuery->alias;
$query->fromTables[$alias] = array_merge( (array)$subQuery->fromTables, [ $subQuery->alias => $joinTable ] );
$query->joinConditions = array_merge( (array)$query->joinConditions, (array)$subQuery->joinConditions );

} else {
$query->fromTables[$alias] = $joinTable;
}

$query->joinConditions[$alias] = [ $joinType . ' JOIN', "$joinField$op=" . $subQuery->joinfield ];

$this->fromTables[$subQuery->alias] = $joinTable;

ksort($this->fromTables);
$this->joinConditions[$subQuery->alias] = [ $joinType . ' JOIN', "$joinField$op=" . $subQuery->joinfield ];

$query->from .= " $joinType JOIN $t ON $joinField$op=" . $subQuery->joinfield;

$query->from .= " $joinType JOIN $t ON $joinField$op=" . $subQuery->joinfield;
if ( $joinType === 'LEFT' ) {
$query->where .= ( ( $query->where === '' ) ? '' : ' AND ' ) . '(' . $subQuery->joinfield . ' IS NULL)';
}
Expand Down
34 changes: 17 additions & 17 deletions formats/datatables/SearchPanes.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@

namespace SRF\DataTables;

use DataItem as SMWDataItem;
use SMW\DataTypeRegistry;
use SMW\DataValueFactory;
use SMW\DIProperty;
use SMW\DIWikiPage;
use SMW\Query\PrintRequest;
use SMW\Services\ServicesFactory as ApplicationFactory;
use SMW\SQLStore\QueryEngine\HierarchyTempTableBuilder;
use SMW\SQLStore\QueryEngine\QuerySegment;
use SMW\SQLStore\QueryEngineFactory;
use SMW\SQLStore\SQLStore;
use SMW\SQLStore\TableBuilder\FieldType;
use SMWDataItem as DataItem;
use SMW\SQLStore\TableBuilder\TemporaryTableBuilder;
use SMWQueryProcessor;
use SRF\DataTables;
use SMW\SQLStore\QueryEngine\HierarchyTempTableBuilder;
use SMW\SQLStore\TableBuilder\TemporaryTableBuilder;

class SearchPanes {
/** @const DataTables */
Expand Down Expand Up @@ -182,7 +182,7 @@ private function getPanesOptions(

$tables = $querySegmentListProcessor->fromTables;
$joins = $querySegmentListProcessor->joinConditions;

$tables[$qobj->alias] = $qobj->joinTable;

$conds = $qobj->where;
Expand All @@ -199,15 +199,15 @@ private function getPanesOptions(
$fields_ = [ 'count' => 'COUNT(*)' ];
$conds_ = $conds;
$joins_ = $joins;
$joins_['insts'] = [ 'JOIN', [ "$qobj->alias.smw_id = insts.s_id" ] ];
$joins_['insts'] = [ 'JOIN', [ "$qobj->alias.smw_id = insts.s_id" ] ];

$res = $this->connection->select(
$tables_,
$fields_,
$conds_,
__METHOD__,
$sql_options_,
$joins_
$tables_,
$fields_,
$conds_,
__METHOD__,
$sql_options_,
$joins_
);

$row = $res->fetchRow();
Expand Down Expand Up @@ -241,8 +241,8 @@ private function getPanesOptions(
$tables_['insts'] = 'smw_fpt_inst';
$tables_['i'] = SQLStore::ID_TABLE;
$joins_ = $joins;
$joins_['insts'] = [ 'JOIN', [ "$qobj->alias.smw_id = insts.s_id" ] ];
$joins_['i'] = [ 'JOIN', [ 'i.smw_id = insts.o_id' ] ];
$joins_['insts'] = [ 'JOIN', [ "$qobj->alias.smw_id = insts.s_id" ] ];
$joins_['i'] = [ 'JOIN', [ 'i.smw_id = insts.o_id' ] ];
$conds_ = $conds;
$fields_ = "COUNT($groupBy) AS count, i.smw_id, i.smw_title, i.smw_namespace, i.smw_iw, i.smw_sort, i.smw_subobject";

Expand Down Expand Up @@ -333,12 +333,12 @@ private function getPanesOptions(
$joins_ = $joins;
$conds_ = $conds;

if ($isIdField) {
if ( $isIdField ) {
$tables_['i'] = SQLStore::ID_TABLE;
$joins_['i'] = [ 'JOIN', "$p_alias.o_id = i.smw_id" ];
$conds_ .= !empty( $conds_ ) ? ' AND' : '';
$conds_ .= ' i.smw_iw != ' . $this->connection->addQuotes(SMW_SQL3_SMWIW_OUTDATED);
$conds_ .= ' AND i.smw_iw != ' . $this->connection->addQuotes(SMW_SQL3_SMWDELETEIW);
$conds_ .= ' i.smw_iw != ' . $this->connection->addQuotes( SMW_SQL3_SMWIW_OUTDATED );
$conds_ .= ' AND i.smw_iw != ' . $this->connection->addQuotes( SMW_SQL3_SMWDELETEIW );
}

$res = $this->connection->select(
Expand Down