r75826 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75825‎ | r75826 | r75827 >
Date:20:44, 1 November 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Fixed issue with comparator handling, needed to use array_flip instead of array_reverse
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryLanguage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryLanguage.php
@@ -53,6 +53,7 @@
5454 */
5555 public static function getComparatorFromString( $string, $defaultComparator = SMW_CMP_EQ ) {
5656 self::initializeComparators();
 57+ if ( $string == '' ) return SMW_CMP_EQ;
5758 return array_key_exists( $string, self::$comparators ) ? self::$comparators[$string] : $defaultComparator;
5859 }
5960
@@ -70,10 +71,13 @@
7172 static $reverseCache = false;
7273
7374 if ( $reverseCache === false ) {
74 - $reverseCache = array_reverse( self::$comparators );
 75+ $reverseCache = array_flip( self::$comparators );
7576 }
7677
77 - if ( array_key_exists( $comparator, $reverseCache ) ) {
 78+ if ( $comparator == SMW_CMP_EQ ) {
 79+ return '';
 80+ }
 81+ else if ( array_key_exists( $comparator, $reverseCache ) ) {
7882 return $reverseCache[$comparator];
7983 }
8084 else {
@@ -107,7 +111,6 @@
108112 '≥' => SMW_CMP_GEQ,
109113 '!' => SMW_CMP_NEQ,
110114 '~' => SMW_CMP_LIKE,
111 - '' => SMW_CMP_EQ,
112115 );
113116
114117 $allowedComparators = explode( '|', $smwgQComparators );

Status & tagging log