Bug #30486

Typoscript select join broken

Added by Christof Rodejohann about 8 years ago. Updated about 1 year ago.

Must have
Target version:
Start date:
Due date:
% Done:


Estimated time:
2.00 h
TYPO3 Version:
PHP Version:
Is Regression:
Sprint Focus:


The solution to #17284 has unwanted side effects.

You can find the following code in line 7421 in file typo3/sysext/cms/tslib/class.tslib_content.php

$queryParts['SELECT'] .= ',uid,pid';

If selecFields is set, any select query gets ',uid,pid' added. This breaks any typoscript join. When using a two tables join and the bare column 'uid' is added to field list, it is always ambiguous and results in a mysql error.

This might be relevant to other releases to (4.6, 4.5, 4.4), because the patch was applied there as well.

Related issues

Duplicates TYPO3 Core - Bug #29783: getQuery: fields explicilty added on select <table>.* : Error: ambigious parameter uid Closed 2011-10-11
Follows TYPO3 Core - Bug #17284: no content in workspace preview when using select.selectFields Closed 2007-05-07

Associated revisions

Revision 1afc0014 (diff)
Added by Björn Pedersen about 8 years ago

[BUGFIX] Don't add uid,pid if <table>.'*' is present in field list.

tx_cal_tsservice uses queries with select <tablename>.* and
complex joins. This breaks due to the unconditionl adding of uid,pid
if the query is set.

Do not add uid,pid,... to field list if the field list already contains a
'*' or the repective field is in the list.

To keep the code easier to read, the sanitizing has been moved
to a seperate function.

The regexp matching is necessary to detect fields like post_uid
(comments extension).

Change-Id: I50332c22e627ea452aaee233fdbbdf3dd426a1b6
Resolves: #29783,#30486
Releases: 4.6
Reviewed-on: http://review.typo3.org/4974
Reviewed-by: Benjamin Mack
Tested-by: Benjamin Mack
Reviewed-by: Christof Rodejohann
Tested-by: Christof Rodejohann
Reviewed-by: Tolleiv Nietsch
Tested-by: Tolleiv Nietsch


#1 Updated by Steffen Gebert about 8 years ago

  • Target version deleted (4.6.0-RC1)

#2 Updated by Steffen Gebert about 8 years ago

  • Status changed from New to Needs Feedback

Could you please provide a simple example to reproduce?

#3 Updated by Christof Rodejohann about 8 years ago

Here you go:

page = PAGE
page.10 = COA
page.10 {

  10 = CONTENT
  10 {
    table = tt_content
    select {            
      selectFields = tt_content.header,be_users.username
      join = be_users ON tt_content.cruser_id = be_users.uid
    renderObj = COA
    renderObj {
      10 = TEXT
      10.field = header

      20 = TEXT
      20.field = username

results in


Column 'uid' in field list is ambiguous

SELECT tt_content.header,be_users.username,uid,pid,t3ver_state FROM tt_content JOIN be_users ON tt_content.cruser_id = be_users.uid WHERE tt_content.pid IN (15) AND tt_content.deleted=0 AND tt_content.t3ver_state<=0 AND tt_content.pid!=-1 AND tt_content.hidden=0 AND tt_content.starttime<=1317397620 AND (tt_content.endtime=0 OR tt_content.endtime>1317397620) AND (tt_content.fe_group='' OR tt_content.fe_group IS NULL OR tt_content.fe_group='0' OR FIND_IN_SET('0',tt_content.fe_group) OR FIND_IN_SET('-1',tt_content.fe_group))

require#78 // include#417 // TSpagegen::renderContent#74 // tslib_cObj->cObjGet#303 // tslib_cObj->cObjGetSingle#548 // tslib_content_ContentObjectArray->render#601 // tslib_cObj->cObjGet#48 // tslib_cObj->cObjGetSingle#548 // tslib_content_Content->render#601 // tslib_cObj->exec_getQuery#101 // t3lib_DB->exec_SELECT_queryArray#7345 // t3lib_DB->exec_SELECTquery#258 // t3lib_DB->debug#191

#4 Updated by Peter Niederlag about 8 years ago

  • Status changed from Needs Feedback to Accepted
  • Estimated time set to 2.00 h
  • Complexity set to easy

IMO the $table can just easily be added on the fieldname as $table is already available anyway in patch from #17284 http://forge.typo3.org/projects/typo3v4-core/repository/revisions/e13d917ec8531d572fba295c7cbc06f44ea16750/diff/typo3/sysext/cms/tslib/class.tslib_content.php
Christoph, could you mabe create/submit a proper patch?

#5 Updated by Xavier Perseguers about 8 years ago

The table can be added, yes, but I guess one may have to take care of proper possible aliasing

#6 Updated by Helmut Hummel about 8 years ago

  • Status changed from Accepted to Resolved

Resolved as duplicate.

Older branches luckily are not affected, as issue #17284 has been blocked for these branches (see https://review.typo3.org/4951 and https://review.typo3.org/4950)

#7 Updated by Benni Mack about 1 year ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF