Bug #43114
closed
sanitizeSelectPart - select CONTENT using DISTINCT
Added by GAYA La Nouvelle Agence about 12 years ago.
Updated over 4 years ago.
Description
Hi,
I've encounter a problem while upgrading to 4.5.22. The sanitizeSelectPart() method was introduced (backported from 4.6 I think) and poses a new problem while using DISTINCT directive. Ex :
test = CONTENT
test {
table = tx_test
select.selectFields = DISTINCT as test
}
The sanitizeSelectPart method will add uid and pid in select clause and so... it won't do what we expect
I saw that some exception was already introduced (count|max|min|avg|sum). Adding distinct will solved the problem.
I don't understand why these "necessaryFields" (uid, pid) were introduced cause in many cases they are not necessary, but this method doesn't smell good and adding some exceptions like it was already done smell worse...
small correction in the selectfield example :
test = CONTENT
test {
table = tx_test
select.selectFields = DISTINCT(my_field) as test
}
- Assignee deleted (
Michael Stucki)
Please don't assign tickets without asking back!
- Target version changed from 4.5.23 to 4.5.24
A patch could simply be done by adding distinct exception :
typo3_src-4.7.7/typo3/sysext/cms/tslib/class.tslib_content.php
7852c7852
< && !preg_match('/(count|max|min|avg|sum)\([^\)]+\)/i', $selectPart)) {
---
&& !preg_match('/(count|max|min|avg|sum|distinct)\([^\)]+\)/i', $selectPart)) {
8100c8100
- Target version changed from 4.5.24 to 4.5.26
- Target version changed from 4.5.26 to 7.2 (Frontend)
- Is Regression set to No
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/38372
- Target version changed from 7.2 (Frontend) to 7.4 (Backend)
- Target version changed from 7.4 (Backend) to 7.5
- Status changed from Under Review to New
- Status changed from New to Under Review
- Target version deleted (
7.5)
- Status changed from Under Review to New
- Status changed from New to Under Review
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
- Status changed from Resolved to Closed
Also available in: Atom
PDF