r94703 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94702‎ | r94703 | r94704 >
Date:22:45, 16 August 2011
Author:yaron
Status:deferred (Comments)
Tags:
Comment:
Removed support for SMW < 1.5, and removed almost-entirely-unnecessary wfLoadExtensionMessages() call
Modified paths:
  • /trunk/extensions/SemanticCompoundQueries/SCQ_QueryProcessor.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticCompoundQueries/SCQ_QueryProcessor.php
@@ -27,7 +27,6 @@
2828 array_shift( $params ); // We already know the $parser.
2929
3030 $other_params = array();
31 - $query_result = null;
3231 $results = array();
3332
3433 foreach ( $params as $param ) {
@@ -38,15 +37,7 @@
3938 $sub_params = self::getSubParams( $param );
4039 $next_result = self::getQueryResultFromFunctionParams( $sub_params, SMW_OUTPUT_WIKI );
4140
42 - if ( method_exists( $next_result, 'getResults' ) ) { // SMW 1.5+
43 - $results = self::mergeSMWQueryResults( $results, $next_result->getResults() );
44 - } else {
45 - if ( $query_result == null ) {
46 - $query_result = new SCQQueryResult( $next_result->getPrintRequests(), new SMWQuery() );
47 - }
48 -
49 - $query_result->addResult( $next_result );
50 - }
 41+ $results = self::mergeSMWQueryResults( $results, $next_result->getResults() );
5142 } else {
5243 $parts = explode( '=', $param, 2 );
5344
@@ -56,14 +47,9 @@
5748 }
5849 }
5950
60 - // SMW 1.5+
61 - if ( is_null( $query_result ) ) {
62 - $query_result = new SCQQueryResult( $next_result->getPrintRequests(), new SMWQuery(), $results, smwfGetStore() );
63 - }
64 -
 51+ $query_result = new SCQQueryResult( $next_result->getPrintRequests(), new SMWQuery(), $results, smwfGetStore() );
6552 $result = self::getResultFromQueryResult( $query_result, $other_params, SMW_OUTPUT_WIKI );
6653 } else {
67 - wfLoadExtensionMessages( 'SemanticMediaWiki' );
6854 $result = smwfEncodeMessages( array( wfMsgForContent( 'smw_iq_disabled' ) ) );
6955 }
7056
@@ -189,12 +175,8 @@
190176 $display_options[$key] = $value;
191177 }
192178
193 - if ( method_exists( $query_result, 'getResults' ) ) { // SMW 1.5+
194 - foreach ( $query_result->getResults() as $wiki_page ) {
195 - $wiki_page->display_options = $display_options;
196 - }
197 - } else {
198 - $query_result->display_options = $display_options;
 179+ foreach ( $query_result->getResults() as $wiki_page ) {
 180+ $wiki_page->display_options = $display_options;
199181 }
200182 }
201183

Comments

#Comment by Jeroen De Dauw (talk | contribs)   22:55, 16 August 2011

The wfLoadExtensionMessages is still needed for MW 1.15.x. You can put it in such an if block:

if ( version_compare( $wgVersion, '1.16', '<' ) ) {

Or you can call smwfLoadExtensionMessages instead. Do note that this later function was added in SMW 1.5.1, so won't work for 1.5. Then again, people up'ing SCQ to the latest are unlikely to have 1.5 anyway.

#Comment by Yaron Koren (talk | contribs)   23:10, 16 August 2011

That's true; but this code is only called when there's an error - when $smwgQEnabled is false - which essentially never happens - so I'm not that worried about it.