Bug #43114

sanitizeSelectPart - select CONTENT using DISTINCT

Added by GAYA La Nouvelle Agence almost 8 years ago. Updated 7 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
TypoScript
Target version:
-
Start date:
2012-11-19
Due date:
% Done:

100%

TYPO3 Version:
4.5
PHP Version:
5.3
Tags:
Complexity:
easy
Is Regression:
No
Sprint Focus:

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...


Related issues

Related to TYPO3 Core - Bug #34152: stdWrap function numRows() fails in 4.6 due to wrong SELECT clause Closed 2012-02-21

Associated revisions

Revision 7002c086 (diff)
Added by Susanne Moog 8 months ago

[BUGFIX] Allow "distinct" in select.selectFields

Add "distinct" into the whitelist of allowed select parts.

Resolves: #43114
Releases: master, 9.5
Change-Id: I8ae6561ff6067117b9d5acb6c976966fecaee96a
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/38372
Tested-by: TYPO3com <>
Tested-by: Benni Mack <>
Tested-by: Frank Nägler <>
Reviewed-by: Benni Mack <>
Reviewed-by: Daniel Goerz <>
Reviewed-by: Frank Nägler <>

Revision f4add4d1 (diff)
Added by Susanne Moog 8 months ago

[BUGFIX] Allow "distinct" in select.selectFields

Add "distinct" into the whitelist of allowed select parts.

Resolves: #43114
Releases: master, 9.5
Change-Id: I8ae6561ff6067117b9d5acb6c976966fecaee96a
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63471
Tested-by: TYPO3com <>
Tested-by: Frank Nägler <>
Reviewed-by: Frank Nägler <>

History

#1 Updated by GAYA La Nouvelle Agence almost 8 years ago

small correction in the selectfield example :

test = CONTENT
test {
table = tx_test
select.selectFields = DISTINCT(my_field) as test
}

#2 Updated by Michael Stucki almost 8 years ago

  • Assignee deleted (Michael Stucki)

Please don't assign tickets without asking back!

#3 Updated by GAYA La Nouvelle Agence over 7 years ago

  • 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

#4 Updated by GAYA La Nouvelle Agence over 7 years ago

  • Target version changed from 4.5.24 to 4.5.26

#5 Updated by Mathias Schreiber almost 6 years ago

  • Target version changed from 4.5.26 to 7.2 (Frontend)
  • Is Regression set to No

#6 Updated by Gerrit Code Review over 5 years ago

  • 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

#7 Updated by Benni Mack over 5 years ago

  • Target version changed from 7.2 (Frontend) to 7.4 (Backend)

#8 Updated by Susanne Moog about 5 years ago

  • Target version changed from 7.4 (Backend) to 7.5

#9 Updated by Andreas Fernandez about 5 years ago

  • Status changed from Under Review to New

#10 Updated by Benni Mack about 5 years ago

  • Status changed from New to Under Review
  • Target version deleted (7.5)

#11 Updated by Daniel Goerz almost 5 years ago

  • Status changed from Under Review to New

Patch was abandoned.

#12 Updated by Gerrit Code Review 8 months ago

  • Status changed from New to Under Review

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/38372

#13 Updated by Gerrit Code Review 8 months ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/38372

#14 Updated by Gerrit Code Review 8 months ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63471

#15 Updated by Susanne Moog 8 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#16 Updated by Benni Mack 7 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF