1

I need to display some mathematical/greek symbols in the RTE and later in the frontend. Inserting them via copy/paste or the "Insert characters" option works great, but as soon as I save the text, the inserted symbol get's replaced with a question mark and T3 throws following error:

1: These fields of record 56 in table "tt_content" have not been saved correctly: bodytext! The values might have changed due to type casting of the database.

I think there is an issue with the character set of T3 or my DB, but I don't know where to start looking.

andreas
  • 16,357
  • 12
  • 72
  • 76
Norman
  • 785
  • 7
  • 27

3 Answers3

1

Tested on my 7.6.8 and it seems to work OK. When I login to my mysql and run this query:

SELECT default_character_set_name FROM information_schema.SCHEMATA
    WHERE schema_name = "7_6_local_typo3_org";

(7_6_local_typo3_org is database name) it returns:

+----------------------------+
| default_character_set_name |
+----------------------------+
| utf8                       |
+----------------------------+
1 row in set (0.00 sec)

and also collation:

SELECT default_collation_name FROM information_schema.SCHEMATA
    WHERE schema_name = "7_6_local_typo3_org";
+------------------------+
| default_collation_name |
+------------------------+
| utf8_general_ci        |
+------------------------+
1 row in set (0.00 sec)

Then also I have in my my.cnf (mysql config file):

character-set-server = utf8
collation-server = utf8_general_ci
Jozef Spisiak
  • 853
  • 5
  • 13
  • Well, then the problem isn't the charset. It seems to occur on several T3 7.6.x installations, also tested it on 6.2.25 and it worked there. So the problem is probably T3 itself. – Norman Jun 02 '16 at 14:20
  • 1
    Are those upgraded 7.6 installations or setup from scratch? – Jozef Spisiak Jun 02 '16 at 14:23
  • Both, but all share the same issue. Did you try saving a gamma in the RTE of your installation? – Norman Jun 02 '16 at 14:25
  • 1
    Yes, alfa beta gamma and delta work just fine, small and large versions. Are you sure you are using utf8_general_ci collation and not some language specific collation? – Jozef Spisiak Jun 02 '16 at 17:03
  • Well... actually I'm not. The table `SCHEMATA` contain two rows, both share the `CATALOG_NAME` "def". The first one is utf8_general_ci and its `SCHEMA_NAME` is "information_schema". The second ones `SCHEMA_NAME` is the name of the DB and the `DEFAULT_COLLATION_NAME` here is "latin1_german2_ci". Which one is being used? – Norman Jun 03 '16 at 07:15
  • Oh, I just found out that several columns in tt_content are having latin_1_swedish_ci as collation. This might be the problem, right? :D – Norman Jun 03 '16 at 07:32
  • Fixed it by changing their collation to utf8. Thanks a lot! – Norman Jun 03 '16 at 07:39
0

Similar problem when pasting HTML with UTF-Icons into Raw-HTML content-element in TYPO3-8.7.x but it works when i encode the symbols, for example:

<span class="menuicon">&#8986;</span>
DeppDeeh
  • 33
  • 9
0

Possible reasons for error message

1: These fields of record X in table "tt_content" have not been saved correctly: bodytext! The values might have changed due to type casting of the database.

in a TYPO3 installation (example installation's version: 10.4.20) can be

  • the MySQL/MariaDB tables of this TYPO3 installation are using an inappropriate/outdated character set and/or collation (Step 1 below).
  • this TYPO3 installation is not yet configured to use utf8mb4 for the database (Step 2 below).

TYPO3 supports utf8mb4 since at least version 9.5. With it comes proper Unicode support, including emojis, mathematical symbols, and Greek letters (e.g. ⌚∰β) in CKEditor bodytext.

I migrated my TYPO3 installation's database and configuration to utf8mb4 in the following way, getting rid of the aforementioned error message and saving and displaying Unicode multibyte characters correctly.

Be sure to apply these migrations in a test environment first, then check existing content and test usual content editing scenarios before applying these migrations on a production system to make sure MySQL/MariaDB converted between the character sets correctly and without data loss (truncation).

Step 1

Update TYPO3 database tables to use utf8mb4 as character set and utf8mb4_unicode_ci as collation.

The following bash one-liner loops over all tables in database typo3 and applies these updates. It assumes MySQL/MariaDB root privileges, a password-less socket connection, and a TYPO3 database (table_schema) named typo3. Adapt accordingly. Tested successfully on

  • Debian 11 MariaDB Server (10.5.12-MariaDB-0+deb11u1)
  • Ubuntu 20.04 LTS MySQL Server (8.0.27-0ubuntu0.20.04.1)
for tbl in $(mysql --disable-column-names --batch -e 'select distinct TABLE_NAME from information_schema.tables where table_schema="typo3" and table_type="BASE TABLE";'); do echo "updating table $tbl" && mysql -e "ALTER TABLE typo3.${tbl} CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"; done

To ensure that during this conversion (from a "smaller" encoding to the up-to-four-bytes-per-character utf8mb4 encoding) no (string) data gets lost/truncated, MySQL/MariaDB automatically adapts a text/string column's datatype to a larger text/string datatype, e.g. from TEXT to MEDIUMTEXT.

To restore some TYPO3 (extension) table's column back to its specified datatype, visit TYPO3 backend -> Maintenance -> Analyze Database Structure. This tool will allow to restore those column's original (smaller) datatypes. This may cause data truncations. I'm not sure whether TYPO3 will warn if truncation actually occurs, though assuming the TYPO3 (extension) developers had utf8mb4 in mind when specifying/designing a column's datatype and the user-provided content of a particular database cell is not too large, truncation should not be happening (overview of text/string datatype sizes).

Step 2

Configure TYPO3 to use utf8mb4. For example, when leveraging typo3conf/AdditionalConfiguration.php, have the following configurations in AdditionalConfiguration.php:

// ...

$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['charset'] = 'utf8mb4';
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['tableoptions']['charset'] = 'utf8mb4';
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['tableoptions']['collate'] = 'utf8mb4_unicode_ci';

// ...
Abdull
  • 26,371
  • 26
  • 130
  • 172