diff --git a/typo3/sysext/core/Classes/Database/Schema/DefaultTcaSchema.php b/typo3/sysext/core/Classes/Database/Schema/DefaultTcaSchema.php index 746d1590b7bd7b45531a5b8996f4b938b579db8f..c83ab72c6a2d70250f28c69517a6c46949641c8c 100644 --- a/typo3/sysext/core/Classes/Database/Schema/DefaultTcaSchema.php +++ b/typo3/sysext/core/Classes/Database/Schema/DefaultTcaSchema.php @@ -767,13 +767,25 @@ class DefaultTcaSchema break; case 'input': - $length = $fieldConfig['config']['max'] ?? null; + $length = $fieldConfig['config']['max'] ?? 255; $nullable = $fieldConfig['config']['nullable'] ?? false; + if ($length > 255) { + $tables[$tableName]->addColumn( + $this->quote($fieldName), + Types::TEXT, + [ + 'length' => 65535, + 'default' => $nullable ? null : '', + 'notnull' => !$nullable, + ] + ); + break; + } $tables[$tableName]->addColumn( $this->quote($fieldName), Types::STRING, [ - 'length' => $length ?? 255, + 'length' => $length, 'default' => '', 'notnull' => !$nullable, ] diff --git a/typo3/sysext/core/Tests/Unit/Database/Schema/DefaultTcaSchemaTest.php b/typo3/sysext/core/Tests/Unit/Database/Schema/DefaultTcaSchemaTest.php index bc9b55c7d3deb843903d7bf0e1c3567ee75b641a..9ec757ab1f7bdba63c970865acef58e9caa3397b 100644 --- a/typo3/sysext/core/Tests/Unit/Database/Schema/DefaultTcaSchemaTest.php +++ b/typo3/sysext/core/Tests/Unit/Database/Schema/DefaultTcaSchemaTest.php @@ -1709,7 +1709,7 @@ final class DefaultTcaSchemaTest extends UnitTestCase 'label' => 'aLabel', 'config' => [ 'type' => 'input', - 'max' => 512, + 'max' => 123, ], ]; $result = $this->subject->enrich(['aTable' => $this->defaultTable]); @@ -1717,7 +1717,7 @@ final class DefaultTcaSchemaTest extends UnitTestCase '`input`', Type::getType('string'), [ - 'length' => 512, + 'length' => 123, 'default' => '', 'notnull' => true, ] @@ -1749,6 +1749,55 @@ final class DefaultTcaSchemaTest extends UnitTestCase self::assertSame($expectedColumn->toArray(), $result['aTable']->getColumn('input')->toArray()); } + #[Test] + public function enrichAddsInputAndUsesTextForLongColumns(): void + { + $this->mockDefaultConnectionPlatformInConnectionPool(); + $GLOBALS['TCA']['aTable']['columns']['input'] = [ + 'label' => 'aLabel', + 'config' => [ + 'type' => 'input', + 'max' => 256, + ], + ]; + $result = $this->subject->enrich(['aTable' => $this->defaultTable]); + $expectedColumn = new Column( + '`input`', + Type::getType('text'), + [ + 'length' => 65535, + 'default' => '', + 'notnull' => true, + ] + ); + self::assertSame($expectedColumn->toArray(), $result['aTable']->getColumn('input')->toArray()); + } + + #[Test] + public function enrichAddsInputAndUsesTextForLongColumnsAndNullable(): void + { + $this->mockDefaultConnectionPlatformInConnectionPool(); + $GLOBALS['TCA']['aTable']['columns']['input'] = [ + 'label' => 'aLabel', + 'config' => [ + 'type' => 'input', + 'max' => 512, + 'nullable' => true, + ], + ]; + $result = $this->subject->enrich(['aTable' => $this->defaultTable]); + $expectedColumn = new Column( + '`input`', + Type::getType('text'), + [ + 'length' => 65535, + 'default' => null, + 'notnull' => false, + ] + ); + self::assertSame($expectedColumn->toArray(), $result['aTable']->getColumn('input')->toArray()); + } + #[Test] public function enrichAddsInlineWithMMSet(): void {