From dcf4b710941d49b6d38d4019a4dc065d9a916238 Mon Sep 17 00:00:00 2001 From: "Thomas A. Hirsch" Date: Thu, 15 Dec 2022 19:36:32 +0100 Subject: [PATCH] Not exactly sure, what this fix was used for. It filters out duplicated fields and ignores the case. Looks more like an issue on the application side. --- lib/Doctrine/Table.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/Table.php b/lib/Doctrine/Table.php index a9cad793f..372f1732f 100644 --- a/lib/Doctrine/Table.php +++ b/lib/Doctrine/Table.php @@ -2774,13 +2774,16 @@ public function buildFindByWhere($fieldName) } $fields = array_merge($fields, $ucfirstFields); + // Remove duplicate entries. + $fields = array_unique($fields); + // Sort field names by length - smallest first // and then reverse so that largest is first usort($fields, array($this, 'isGreaterThan')); $fields = array_reverse(array_unique($fields)); // Identify fields and operators - preg_match_all('/(' . implode('|', $fields) . ')(Or|And)?/', $fieldName, $matches); + preg_match_all('/((?i)' . implode('|', $fields) . ')(Or|And)?/', $fieldName, $matches); $fieldsFound = $matches[1]; $operatorFound = $matches[2]; foreach ($operatorFound as &$v) { @@ -2789,7 +2792,7 @@ public function buildFindByWhere($fieldName) // Check if $fieldName has unidentified parts left if (strlen(implode('', $fieldsFound) . implode('', $operatorFound)) !== strlen($fieldName)) { - $expression = preg_replace('/(' . implode('|', $fields) . ')(Or|And)?/', '($1)$2', $fieldName); + $expression = preg_replace('/((?i)' . implode('|', $fields) . ')(Or|And)?/', '($1)$2', $fieldName); throw new Doctrine_Table_Exception('Invalid expression found: ' . $expression); }