fnagel / generic-gallery

TYPO3 extension: Generic Gallery - One gallery to rule them all!
https://extensions.typo3.org/extension/generic_gallery/
GNU General Public License v3.0
7 stars 12 forks source link

SQL error: 'Incorrect integer value: '' for column `typo3srh`.`tt_content`.`tx_generic_gallery_collection` #48

Closed cweiske closed 2 years ago

cweiske commented 2 years ago

When creating a gallery plugin with a file collection, saving that and then removing the file collection and saving again, an error occurs:

2: SQL error: 'Incorrect integer value: '' for column typo3srh.tt_content.tx_generic_gallery_collection at row 1' (tt_content:6040)

As suspected in #35, this is because the SQL mode of the MariaDB server is not empty but

$ SELECT @@sql_mode;
STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

The problem can be worked around by modifying the database connection in LocalConfiguration.php:

'DB' => ['Connections' => ['Default' => 'initCommands' => 'SET @@sql_mode="";']]]

TYPO3 core

The TYPO3 core uses the same configuration but does see this bug. Example: pages.mount_pid.

When saving, the DataHandler calls fillInFieldArray, which calls checkValue, which calls checkValueForGroupSelect, which at last calls castReferenceValue - and that one converts the empty string to a 0.

generic_gallery

tt_content.tx_generic_gallery_collection has the exact same settings in Configuration/TCA/Overrides/tt_content.php as pages.mount_pid.

During debugging I found that this configuration changes, and DataHandler has a different config than what is written in the Overrides file: type: inline, foreign_table: sys_file_collection, maxitems: 1, no default

array(5) {
  ["type"]=>  string(6) "inline"
  ["foreign_table"]=>  string(19) "sys_file_collection"
  ["appearance"]=>  array(2) {
    ["collapseAll"]=>    int(0)
    ["expandSingle"]=>    int(1)
  }
  ["maxitems"]=>  int(1)
  ["minitems"]=>  int(0)
}

So the problem is that the conversion to the inline selection removes the default value, and castReferenceValue is unable to use it!