Bug #103098
closedDB check must not require a title field of a database table
0%
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.
SELECT `uid`, `pid`, `title` FROM `sys_products_orders_mm_tt_products` WHERE `pid` NOT IN ( ...
Files
Updated by Franz Holzinger 10 months ago
Here comes the backtrace file.
Updated by Andreas Kienast 9 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']; }
Updated by Franz Holzinger 9 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.
Updated by Christian Kuhn 9 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.
Updated by Franz Holzinger 9 months 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.
Updated by Christian Kuhn 9 months 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?