Ed Hoo has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/257266

Change subject: [Cargo] Fix T120583: #cargo_query HOLDS check used in 
multi-value fields
......................................................................

[Cargo] Fix T120583: #cargo_query HOLDS check used in multi-value fields

Change the HOLDS check to match the field "book", but not the field "bookworm" 
when the field that allows for multiple values is "book".  Makes the match 
case-insensitive since table and column names are usually not case sensitive.

Bug: T120583
Change-Id: I22cffe0ffed72fed72cdf2f83673a0d871313986
---
M CargoSQLQuery.php
1 file changed, 4 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo 
refs/changes/66/257266/1

diff --git a/CargoSQLQuery.php b/CargoSQLQuery.php
index acc0512..83d5b8e 100644
--- a/CargoSQLQuery.php
+++ b/CargoSQLQuery.php
@@ -556,19 +556,19 @@
                        $fieldName = $virtualField['fieldName'];
                        $tableName = $virtualField['tableName'];
 
-                       $likePattern1 = "/\b$tableName\.$fieldName(\s*HOLDS 
LIKE\s*)/";
+                       $likePattern1 = 
"/\b$tableName\.$fieldName".'[^0-9a-zA-Z$_](\s*HOLDS LIKE\s*)/i';
                        $foundLikeMatch1 = preg_match( $likePattern1, 
$this->mWhereStr, $matches );
                        $foundLikeMatch2 = $foundMatch1 = $foundMatch2 = false;
                        if ( !$foundLikeMatch1 ) {
-                               $likePattern2 = "/\b$fieldName(\s*HOLDS 
LIKE\s*)/";
+                               $likePattern2 = 
"/\b$fieldName".'[^0-9a-zA-Z$_](\s*HOLDS LIKE\s*)/i';
                                $foundLikeMatch2 = preg_match( $likePattern2, 
$this->mWhereStr, $matches );
                        }
 
                        if ( !$foundLikeMatch1 && !$foundLikeMatch2 ) {
-                               $pattern1 = 
"/\b$tableName\.$fieldName(\s*HOLDS\s*)?/";
+                               $pattern1 = 
"/\b$tableName\.$fieldName".'[^0-9a-zA-Z$_](\s*HOLDS\s*)?/i';
                                $foundMatch1 = preg_match( $pattern1, 
$this->mWhereStr, $matches );
                                if ( !$foundMatch1 ) {
-                                       $pattern2 = 
"/\b$fieldName(\s*HOLDS\s*)?/";
+                                       $pattern2 = 
"/\b$fieldName".'[^0-9a-zA-Z$_](\s*HOLDS\s*)?/i';
                                        $foundMatch2 = preg_match( $pattern2, 
$this->mWhereStr, $matches );
                                }
                        }

-- 
To view, visit https://gerrit.wikimedia.org/r/257266
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I22cffe0ffed72fed72cdf2f83673a0d871313986
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Ed Hoo <edward....@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to