Brian Wolff has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/342545 )
Change subject: Added use of Database::buildLike() ...................................................................... Added use of Database::buildLike() Backport from PageForms bb42c6f401b9 Change-Id: I1c28fb97a4253c41c2c66d5bc9fb010afb42c8ea --- M includes/SF_ValuesUtils.php 1 file changed, 8 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticForms refs/changes/45/342545/1 diff --git a/includes/SF_ValuesUtils.php b/includes/SF_ValuesUtils.php index 2bc88da..3158a24 100644 --- a/includes/SF_ValuesUtils.php +++ b/includes/SF_ValuesUtils.php @@ -395,6 +395,7 @@ /** * Returns a SQL condition for autocompletion substring value in a column. + * * @param string $value_column Value column name * @param string $substring Substring to look for * @return SQL condition for use in WHERE clause @@ -404,6 +405,8 @@ */ public static function getSQLConditionForAutocompleteInColumn( $column, $substring, $replaceSpaces = true ) { global $wgDBtype, $sfgAutocompleteOnAllChars; + + $db = wfGetDB( DB_SLAVE ); // CONVERT() is also supported in PostgreSQL, but it doesn't // seem to work the same way. @@ -417,15 +420,14 @@ if ( $replaceSpaces ) { $substring = str_replace( ' ', '_', $substring ); } - $substring = str_replace( "'", "\'", $substring ); - $substring = str_replace( '_', '\_', $substring ); - $substring = str_replace( '%', '\%', $substring ); if ( $sfgAutocompleteOnAllChars ) { - return "$column_value LIKE '%$substring%'"; + return $column_value . $db->buildLike( $substring, $db->anyString() ); } else { - $spaceRepresentation = $replaceSpaces ? '\_' : ' '; - return "$column_value LIKE '$substring%' OR $column_value LIKE '%" . $spaceRepresentation . $substring . "%'"; + $spaceRepresentation = $replaceSpaces ? '_' : ' '; + return $column_value . $db->buildLike( $substring, $db->anyString() ) . + ' OR ' .$column_value . + $db->buildLike( $db->anyString(), $spaceRepresentation . $substring, $db->anyString() ); } } -- To view, visit https://gerrit.wikimedia.org/r/342545 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1c28fb97a4253c41c2c66d5bc9fb010afb42c8ea Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/SemanticForms Gerrit-Branch: 3.7 Gerrit-Owner: Brian Wolff <bawolff...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits