Bug #81043

TCA type select & MySQL-strict mode leads to exception

Added by Cihan Yesilöz over 2 years ago. Updated 11 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Extbase
Start date:
2017-04-27
Due date:
% Done:

100%

TYPO3 Version:
8
PHP Version:
7.0
Tags:
Complexity:
Is Regression:
Yes
Sprint Focus:

Description

TCA of type "select" leads to an exception when used with MySQL-strict-mode "STRICT_TRANS_TABLES".

TCA-configuration:

        'status' => [
            'exclude' => 1,
            'label' => 'Status',
            'config' => array(
                'type' => 'select',
                'renderType' => 'selectSingle',
                'items' => (
                    array('Level-1', 1),
                    array('Status-2', 2),
                    array('Status-3', 3)
                ),
                'default' => 1,
            ),
        ],

PHP-Code:

<?php
        $newUser = new User();
        $newUser->setStatus(1);
        $userRepository = $this->objectManager->get(UserRepository::class);
        $userRepository->add($newUser);
        $persistenceManager = $this->objectManager->get(PersistenceManager::class);
        $persistenceManager->persistAll();
?>

The exception thrown by TYPO3:

#1470230766: Incorrect integer value: '' for column 'status' at row 1 (More information)

When I revert the change in "typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapFactory.php" in Line 335 in Commit https://github.com/TYPO3/TYPO3.CMS/commit/38a1bc5dd7990b63e45c0419065cd02fe91187e9#diff-a8aa95385a4a9a2e39c52f857dbc0e28 the error disappears. The error also disappears when I disable the sql strict mode "STRICT_TRANS_TABLES"

Associated revisions

Revision 1f81eac3 (diff)
Added by Helmut Hummel about 2 years ago

[BUGFIX] Do not detect single select fields as relation

With https://review.typo3.org/50879/ all TCA select fields
are detected as relation to many, even when they are configured
as simple static select.

This leads to the row value to be pre-set as string (to hold comma
separated values), which leads to an exception in MySQL Strict Mode
when the select value field is defined as integer.

Therefore only detect renderType === selectMultipleSideBySide
as relational field

Resolves: #81043
Releases: master, 8.7
Change-Id: I54effaace3eb19034d86a9a74bbd5cc207e867f1
Reviewed-on: https://review.typo3.org/53565
Reviewed-by: Benni Mack <>
Reviewed-by: Henning Liebe <>
Reviewed-by: Tymoteusz Motylewski <>
Tested-by: Tymoteusz Motylewski <>
Reviewed-by: Georg Ringer <>
Tested-by: Georg Ringer <>

Revision c50564aa (diff)
Added by Helmut Hummel about 2 years ago

[BUGFIX] Do not detect single select fields as relation

With https://review.typo3.org/50879/ all TCA select fields
are detected as relation to many, even when they are configured
as simple static select.

This leads to the row value to be pre-set as string (to hold comma
separated values), which leads to an exception in MySQL Strict Mode
when the select value field is defined as integer.

Therefore only detect renderType === selectMultipleSideBySide
as relational field

Resolves: #81043
Releases: master, 8.7
Change-Id: I54effaace3eb19034d86a9a74bbd5cc207e867f1
Reviewed-on: https://review.typo3.org/53655
Reviewed-by: Georg Ringer <>
Tested-by: Georg Ringer <>

History

#1 Updated by Cihan Yesilöz over 2 years ago

  • Is Regression set to Yes

#2 Updated by Cihan Yesilöz over 2 years ago

  • Description updated (diff)

#3 Updated by Wouter Wolters over 2 years ago

  • Assignee deleted (Christian Kuhn)

#4 Updated by Cihan Yesilöz over 2 years ago

  • Description updated (diff)

#5 Updated by Benni Mack over 2 years ago

  • Target version changed from 8 LTS to Candidate for patchlevel

#6 Updated by Alex Kellner about 2 years ago

I can confirm the same issue for extension powermail with field tx_powermail_domain_model_answer.value_type

#7 Updated by Oleg Karun about 2 years ago

Alex Kellner wrote:

I can confirm the same issue for extension powermail with field tx_powermail_domain_model_answer.value_type

The same problem. Fixed in TYPO3 8.7.x by adding in
AdditionalConfiguration.php

$GLOBALS['TYPO3_CONF_VARS']['DB'] = array(
        'Connections' => [
            'Default' => [
                'charset' => 'utf8',
                //... here your DB settings
                'initCommands' => 'SET sql_mode=\'\';',
            ],
        ],
);

#8 Updated by Gerrit Code Review about 2 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53565

#9 Updated by Gerrit Code Review about 2 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53565

#10 Updated by Gerrit Code Review about 2 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53565

#11 Updated by Gerrit Code Review about 2 years ago

Patch set 1 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53655

#12 Updated by Helmut Hummel about 2 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#13 Updated by Benni Mack 11 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF