Project

General

Profile

Actions

Bug #103098

closed

DB check must not require a title field of a database table

Added by Franz Holzinger 2 months ago. Updated about 1 month ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
Backend User Interface
Target version:
-
Start date:
2024-02-10
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.2
Tags:
database
Complexity:
Is Regression:
Sprint Focus:

Description

When I run the DB Check module, then an exception is raised:

*#1054 Doctrine\DBAL\Exception\InvalidFieldNameException
An exception occurred while executing a query: Unknown column 'title' in 'field list' *

This must not happen. The TYPO3 Documentation says that only the fields uid and pid are required.

https://docs.typo3.org/m/typo3/reference-coreapi/12.4/en-us/ApiOverview/Database/DatabaseStructure/Index.html

SELECT `uid`, `pid`, `title` FROM `sys_products_orders_mm_tt_products` WHERE `pid` NOT IN ( ...


Files

fehler-103098-db-field-title.txt (91.1 KB) fehler-103098-db-field-title.txt Franz Holzinger, 2024-02-10 21:05
Actions #1

Updated by Franz Holzinger 2 months ago

Here comes the backtrace file.

Actions #2

Updated by Andreas Kienast 2 months ago

  • Status changed from New to Needs Feedback

Do you by chance have TCA for your mm-table defined? The code in DatabaseIntegrityCheck->lostRecords() has a check for ctrl/label, implying this is defined in your TCA, but not in your ext_tables.sql:

if (!empty($GLOBALS['TCA'][$table]['ctrl']['label'])) {
    $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['label'];
}

Actions #3

Updated by Franz Holzinger 2 months ago

There is a wrong TCA for a mm table.

$result = [
    'ctrl' => [
        'title' => 'LLL:EXT:' . $extensionKey . $languageSubpath . 'locallang_db.xlf:tt_products_attribute_mm_graduated_price',
        'label' => 'title',

This must be changed into

$result = [
    'ctrl' => [
        'title' => 'LLL:EXT:' . $extensionKey . $languageSubpath . 'locallang_db.xlf:tt_products_attribute_mm_graduated_price',
        'label' => 'uid',

Then this error message disappears.

However the TYPO3 code for DB check should raise an exception about the real error that the 'title' field is not in the TCA and not in the ext_tables.sql. This would help a lot.

Actions #4

Updated by Christian Kuhn about 2 months ago · Edited

  • Status changed from Needs Feedback to Rejected

Hey.

So this was a bug in the extension.

I don't agree to your claim "the TYPO3 code for DB check should raise an exception about the real error that the 'title' field is not in the TCA and not in the ext_tables.sql", though:
TYPO3 takes TCA definitions as granted at many places throughout the core. The system in general does not check for existence of DB fields before querying them. At least not at runtime. The DatabaseIntegrityCheck should not be an exception here.

We could potentially create some checker - for instance in the install tool - that looks for integrity issues between TCA definitions and DB field existence in general, but I fear that wouldn't help that much, considering the fact that core already auto-creates tons of DB fields even without having a definition in ext_tables.sql already. I'd say your case is rather edgy - so edgy that you bug was within your extension for probably quite some time already, which makes such a core functionality even more questionable. Also, the backtrace revealed your configuration error quite quickly, the combination of "'title' column queried, plus backtrace" is pretty clear.

As such, I'll reject the issue for now, and will not create a new issue for a potential 'checker' since that feature would imho be quite limited in its usefulness.

Actions #5

Updated by Franz Holzinger about 1 month ago · Edited

@Christian Kuhn: Why do you claim that this would be a bug in the extension?
Can you please explain this?

See https://docs.typo3.org/m/typo3/reference-tca/main/en-us/BestPractises/CommonFields.html .

The only mandatory TCA fields are uid and pid.
So TYPO3 Core must no rely on the 'title' or any other field to be set.

Please invest just 1 minute for it: Raise a RuntimeException with a clear error message that tells that table 'XXX' is missing the field 'title' in the TCA.
This costs you only one minute.

Actions #6

Updated by Christian Kuhn about 1 month ago · Edited

Huh? You do not skip the 'label' field in TCA (missing label is sanitized in the class as far as I can see), but you actively set it to some column name that does not exist. You are essentially asking to look up existence of field names in DB before we query them, because your extension came with broken TCA. That is what I think we should refuse to implement. Did I misunderstand something?

Actions

Also available in: Atom PDF