Issue Bug Closed

#50383Extbase doesn't support TCA ctrl type based of a related record

Daniel Ostmann 07/24/13, 14:52 updated 04/23/26, 11:51

Description

I wanted to add a new field (simple textarea) to the sys_file_reference. I wrote a module that subclasses TYPO3\CMS\Extbase\Domain\Model\FileReference and the new model provides the new field. All seems to work in backend.

In frontend i get this SQL Error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':type='2') AND sys_file_reference.deleted=0 AND sys_file_reference.t3ver_state<=' at line 1: SELECT sys_file_reference.* FROM sys_file_reference WHERE ((sys_file_reference.uid_foreign = '14' AND sys_file_reference.tablenames = 'tt_content') AND sys_file_reference.fieldname = 'pxf_teaser_images') AND (sys_file_reference.uid_local:type='2') AND sys_file_reference.deleted=0 AND sys_file_reference.t3ver_state<=0 AND sys_file_reference.pid<>-1 AND sys_file_reference.hidden=0 ORDER BY sys_file_reference.sorting_foreign ASC

Taking a closer look you’ll see that the where clause, that checks for “uid_local:type” causes the error:

AND (sys_file_reference.uid_local:type='2') AND

In TCA of the sys_file_reference there is a field

'type' => 'uid_local:type',

So i think this value isn’t resolved in frontend?

I fixed it by just removing “(sys_file_reference.uid_local:type=‘2’)” from the whereclause, in:

\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::buildQuery()

    public function buildQuery(array $sql) {
        foreach ($sql['additionalWhereClause'] as $key => $clause) {
            if ($clause == "(sys_file_reference.uid_local:type='2')") unset($sql['additionalWhereClause'][$key]);
        }

Well, this is not the final solution of course. It just helped me solving the problem. That’s why i didn’t provide a patch yet. I just don’t know how to solve it…

Reviews 1

Files 1

History 812

  1. Daniel Ostmann commented and changed attached patch_commit_119fc407b7d7.patch <span data-processor="relativetime" data-value="2013-07-29T13:59:53+00:00" > 07/29/13, 13:59 </span>

    I created a patch to solve it.

    In this patch the method \TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::addRecordTypeConstraint() checks if there’s a colon within the type-field. If so, it resolves it and creates the correct JOIN sql.

    This patch also extends \TYPO3\CMS\Extbase\Domain\Model\File and \TYPO3\CMS\Extbase\Domain\Model\FileReference and solves my problem.

    How can i push it to review workflow?

  2. Wouter Wolters commented <span data-processor="relativetime" data-value="2013-07-29T14:57:46+00:00" > 07/29/13, 14:57 </span>

    You can try to follow the guideline at http://wiki.typo3.org/Contribution_Walkthrough_with_CommandLine
    if you need help don’t hesistate to contact me

  3. Philipp Gampe commented and changed project id category <span data-processor="relativetime" data-value="2013-07-29T19:07:29+00:00" > 07/29/13, 19:07 </span>

    Moving to extbase tracker

  4. Gerrit Code Review changed status New Under Review <span data-processor="relativetime" data-value="2013-07-29T22:13:04+00:00" > 07/29/13, 22:13 </span> Patch set 2 for branch *master* has been pushed to the review server. It is available at https://review.typo3.org/22673

  5. Gerrit Code Review <span data-processor="relativetime" data-value="2013-07-29T22:16:23+00:00" > 07/29/13, 22:16 </span> Patch set 3 for branch *master* has been pushed to the review server. It is available at https://review.typo3.org/22673

  6. Gerrit Code Review <span data-processor="relativetime" data-value="2013-07-29T22:18:55+00:00" > 07/29/13, 22:18 </span> Patch set 4 for branch *master* has been pushed to the review server. It is available at https://review.typo3.org/22673

  7. Gerrit Code Review <span data-processor="relativetime" data-value="2013-07-29T22:25:09+00:00" > 07/29/13, 22:25 </span> Patch set 5 for branch *master* has been pushed to the review server. It is available at https://review.typo3.org/22673

  8. Marc Bastian Heinrichs commented and changed subject SQL Error while extending sys_file_reference Extbase doesn't support TCA ctrl type based of a related record priority Must have Should have <span data-processor="relativetime" data-value="2014-02-15T15:26:07+00:00" > 02/15/14, 15:26 </span>

    Hey, here some things are mixed up, so I cleaned up the title.

    The problem is caused by using single table inheritance for the table sys_file_reference and the fact that ATM Extbase has no support for setting the ctrl type based of a related record in TCA, which is used by sys_file_reference.

    So I’m basically fine with your changed in Typo3DbBackend::addRecordTypeConstraint, but the detection of ‘:’ in the type should be already done in DataMapFactory and be saved in a additional setting for the RecordTypeTableName. Based on this the different query should be build in addRecordTypeConstraint.

  9. Alexander Opitz commented and changed project id category TYPO3 Version 6.1 PHP Version 5.4 Is Regression 0 <span data-processor="relativetime" data-value="2014-09-24T11:23:01+00:00" > 09/24/14, 11:23 </span>

    Hi Daniel,

    would you be so nice and rework your patches to the comments from Marc?

  10. Daniel Ostmann commented <span data-processor="relativetime" data-value="2014-09-24T11:28:46+00:00" > 09/24/14, 11:28 </span>

    Yes, but I don’t have the time at the moment…

  11. Christian Kuhn commented and changed status Under Review New <span data-processor="relativetime" data-value="2015-03-02T20:56:23+00:00" > 03/02/15, 20:56 </span>

    We abandoned the pending patch since nothing happened for a very long time. The issue is probably still valid and could be pushed again.

  12. Christian Kuhn commented and changed status New Closed <span data-processor="relativetime" data-value="2026-04-23T11:51:19+00:00" > 04/23/26, 11:51 </span>

    Hey. Sad facts:
    • issue uncommented for 11 years.
    • unclear it is has been fixed meanwhile with a lot of stuff happening in extbase. And I kinda have the gut feeling this is probably solved, but I must admit I didn’t push time into this now, apart from writing this comment.

    I’m sorry, but I’ll go ahead and close here. If this is still an issue, we should start fresh.