Project

General

Profile

Actions

Bug #50383

open

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

Added by Daniel Ostmann over 11 years ago. Updated over 9 years ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2013-07-24
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
6.1
PHP Version:
5.4
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

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...


Files

patch_commit_119fc407b7d7.patch (3.58 KB) patch_commit_119fc407b7d7.patch Daniel Ostmann, 2013-07-29 13:59
Actions #1

Updated by Daniel Ostmann over 11 years ago

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?

Actions #2

Updated by Wouter Wolters over 11 years ago

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

Actions #3

Updated by Philipp Gampe over 11 years ago

  • Project changed from TYPO3 Core to 534
  • Category deleted (File Abstraction Layer (FAL))

Moving to extbase tracker

Actions #4

Updated by Gerrit Code Review over 11 years ago

  • Status changed from New to Under Review

Patch set 2 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/22673

Actions #5

Updated by Gerrit Code Review over 11 years ago

Patch set 3 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/22673

Actions #6

Updated by Gerrit Code Review over 11 years ago

Patch set 4 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/22673

Actions #7

Updated by Gerrit Code Review over 11 years ago

Patch set 5 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/22673

Actions #8

Updated by Marc Bastian Heinrichs almost 11 years ago

  • Subject changed from SQL Error while extending sys_file_reference to Extbase doesn't support TCA ctrl type based of a related record
  • Priority changed from Must have to Should have

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.

Actions #9

Updated by Alexander Opitz about 10 years ago

  • Project changed from 534 to TYPO3 Core
  • Category set to Extbase
  • TYPO3 Version set to 6.1
  • PHP Version set to 5.4
  • Is Regression set to No

Hi Daniel,

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

Actions #10

Updated by Daniel Ostmann about 10 years ago

Yes, but I don't have the time at the moment...

Actions #11

Updated by Christian Kuhn over 9 years ago

  • Status changed from Under Review to New

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

Actions

Also available in: Atom PDF