Bug #43114

sanitizeSelectPart - select CONTENT using DISTINCT

Added by GAYA La Nouvelle Agence over 6 years ago. Updated over 3 years ago.

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

0%

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

History

#1 Updated by GAYA La Nouvelle Agence over 6 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 over 6 years ago

  • Assignee deleted (Michael Stucki)

Please don't assign tickets without asking back!

#3 Updated by GAYA La Nouvelle Agence about 6 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 about 6 years ago

  • Target version changed from 4.5.24 to 4.5.26

#5 Updated by Mathias Schreiber over 4 years ago

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

#6 Updated by Gerrit Code Review about 4 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 almost 4 years ago

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

#8 Updated by Susanne Moog almost 4 years ago

  • Target version changed from 7.4 (Backend) to 7.5

#9 Updated by Andreas Fernandez over 3 years ago

  • Status changed from Under Review to New

#10 Updated by Benni Mack over 3 years ago

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

#11 Updated by Daniel Goerz over 3 years ago

  • Status changed from Under Review to New

Patch was abandoned.

Also available in: Atom PDF