Bug #30486
closedTyposcript select join broken
0%
Description
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.
Updated by Steffen Gebert about 13 years ago
- Status changed from New to Needs Feedback
Could you please provide a simple example to reproduce?
Updated by Christof Rodejohann about 13 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
caller t3lib_DB::exec_SELECTquery ERROR Column 'uid' in field list is ambiguous lastBuiltQuery 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)) debug_backtrace 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
Updated by Peter Niederlag about 13 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?
Updated by Xavier Perseguers about 13 years ago
The table can be added, yes, but I guess one may have to take care of proper possible aliasing
Updated by Helmut Hummel about 13 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)