r98691 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98690‎ | r98691 | r98692 >
Date:17:08, 2 October 2011
Author:yaron
Status:deferred
Tags:
Comment:
Added sorting of results, fixed typo in variable name added in r98672
Modified paths:
  • /trunk/extensions/SemanticCompoundQueries/SCQ_QueryProcessor.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticCompoundQueries/SCQ_QueryProcessor.php
@@ -11,6 +11,16 @@
1212 class SCQQueryProcessor extends SMWQueryProcessor {
1313
1414 /**
 15+ * Comparison helper function, used in sorting results.
 16+ */
 17+ public static function compareQueryResults( $a, $b ) {
 18+ if ( $a->getDBKey() == $b->getDBKey() ) {
 19+ return 0;
 20+ }
 21+ return ( $a->getDBKey() < $b->getDBKey() ) ? -1 : 1;
 22+ }
 23+
 24+ /**
1525 * Handler for the #compound_query parser function.
1626 *
1727 * @param Parser $parser
@@ -63,12 +73,15 @@
6474 $results = self::mergeSMWQueryResults( $results, $next_result->getResults() );
6575 }
6676
 77+ // Sort results so that they'll show up by page name
 78+ uasort( $results, 'self::compareQueryResults' );
 79+
6780 $query_result = new SCQQueryResult( $next_result->getPrintRequests(), new SMWQuery(), $results, smwfGetStore() );
6881
6982 if ( version_compare( SMW_VERSION, '1.6.1', '>' ) ) {
70 - $printeouts = $next_result->getPrintRequests();
71 - SMWQueryProcessor::addThisPrintout( $printeouts, $other_params );
72 - $other_params = parent::getProcessedParams( $other_params, $printeouts );
 83+ $printouts = $next_result->getPrintRequests();
 84+ SMWQueryProcessor::addThisPrintout( $printouts, $other_params );
 85+ $other_params = parent::getProcessedParams( $other_params, $printouts );
7386 }
7487
7588 return self::getResultFromQueryResult(
@@ -185,7 +198,7 @@
186199 $params = self::getProcessedParams( $params, $extraprintouts, false );
187200 }
188201
189 - $query = self::createQuery( $querystring, $params, $context, null, $extraprintouts );
 202+ $query = self::createQuery( $querystring, $params, $context, null, $extraprintouts );
190203 $query_result = smwfGetStore()->getQueryResult( $query );
191204
192205 foreach ( $query_result->getResults() as $wiki_page ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r102907Follow-up to r98691 - fixed uasort() call for PHP < 5.3yaron20:40, 13 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r98672fix compar with SMW >=1.6.3jeroendedauw14:43, 2 October 2011