Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Add
ESCAPE
keyword for like()
and `notLike() expressions
Values for `like` expressions should be escaping the corresponding like wildcards ($ and _). TYPO3 core provides a `escapeLikeWildcards()` in `QueryBuilder` and on the `Connection`. Under the hood, the php `addcslashes()` method is used to escape wildcards in the value before appending/prepending wildcards. It has been assumed, that `\` as escape character is always the default character throughout all database server vendors and versions - which makes `addcslashes()` the one-shot to use. It has been recently discovered, that if values in the database contains one of these wildcards, for example the underscore `_` and a like expression is built using the escape method, the row cannot be matched in all databases. This relates to the fact, that the generated like expressions do not contains the `ESCAPE` keyword to define which escape character has been used. `doctrine/dbal` has added a corresponding argument to the doctrine/dbal query ExpressionBuilder like() and notLike() method, so this can be set. TYPO3 uses a custom ExpressionBuilder, not extending the doctrine ExpressionBuilder (which will change with upcoming doctrine/dbal v4). This change always adds the `ESCAPE` keyword to like and not like expressions with the hardcoded `\` escape character - except for PostgresSQL. PostgresSQL doesn't like it when ILIKE/NOT ILIKE is used, which the ExpressionBuilder does to mimic case insensitive LIKE/NOT LIKE similar to MySql. This can be made configurable in a dedicated patch and must be done for upgrading to doctrine/dbal 4.x anyway. Resolves: #100874 Releases: main, 12.4, 11.5 Change-Id: Id7eb891ef52e8c6988a605eaadd0afcbcf5176bb Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/79491 Tested-by: Stefan Bürk <stefan@buerk.tech> Tested-by: core-ci <typo3@b13.com> Reviewed-by: Stefan Bürk <stefan@buerk.tech>
- Loading branch information
Showing
5 changed files
with
176 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters