Skip to content

Commit

Permalink
Not exactly sure, what this fix was used for. It filters out duplicat…
Browse files Browse the repository at this point in the history
…ed fields and ignores the case. Looks more like an issue on the application side.
  • Loading branch information
thirsch committed Dec 15, 2022
1 parent 92abb24 commit dcf4b71
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/Doctrine/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}

Expand Down

0 comments on commit dcf4b71

Please sign in to comment.