[TYPO3-core] RFC: Fix for bug #1649
Martin Kutschker
Martin.Kutschker at blackbox.net
Thu Dec 22 11:46:10 CET 2005
Karsten Dambekalns <karsten at typo3.org> writes on
Wed, 21 Dec 2005 18:53:35 +0100 (MET):
> This is a CVS patch request.
>
> Type: Bugfix for
> http://bugs.typo3.org/view.php?id=1649
>
> Branches: HEAD, 3.8(?)
>
> Description:
> When having a self-referencing mm relation the SQL created by
> exec_SELECT_mm_query() in t3lib_db will be wrong, as it will have a
> non-unique table name twice in the list of from tables.
>
> Solution:
> Check for local and foreign table being identical and leave out the
> foreign table from the table list if needed.
I didn't try the patch, but what about this statement:
$mmWhere.= $foreign_table ? $foreign_table.'.uid='.$mm_table.'.uid_foreign' : '';
It's set BEFORE your conditional unsetting of $foreign_table.
Anyway, if you have a self-referecingn relation you still have to have a "2nd" table. So that the statemen mentioned above makes sense. But you have to use SQL aliases.
Shouldn't it therefore read:
$mmWhere .=
($local_table AND $foreign_table) ? ' AND ' : '';
if($foreign_table == $local_table) {
$foreign_table .= '_join';
}
$mmWhere .=
$foreign_table ? $foreign_table.'.uid='.$mm_table.'.uid_foreign' : '';
Masi
More information about the TYPO3-team-core
mailing list