Creating pages tries to assign empty string to integer field
I recently discovered an issue after upgrading to MySQL 5.6 when creating pages.
When creating a page, following $fieldArray is tried to be inserted.
array (\n 'doktype' => '1',\n 'hidden' => '1',\n 'starttime' => '0',\n 'endtime' => '0',\n 'layout' => '0',\n 'url_scheme' => 0,\n 'urltype' => '1',\n 'lastUpdated' => '0',\n 'newUntil' => '0',\n 'cache_timeout' => '0',\n 'shortcut_mode' => '0',\n 'module' => '',\n 'backend_layout' => '',\n 'backend_layout_next_level' => '',\n 'perms_userid' => '1',\n 'perms_groupid' => 0,\n 'perms_user' => 31,\n 'perms_group' => 27,\n 'perms_everybody' => 0,\n 'sorting' => 256,\n 'pid' => 0,\n 'title' => '[Default Title]',\n 'crdate' => 1381052264,\n 'cruser_id' => '1',\n 'tstamp' => 1381052264,\n 't3ver_stage' => 0,\n ),
Which is ok, but the backend_layout and backend_layout_next_level fields are both set as empty strings '', which is tried to set into integer fields. This is a problem with MySQL 5.6 default setup cause it uses: sql_mode=STRICT_TRANS_TABLES ( or at least in osx it does)
This can for sure just be changes, but it might be a wanted configuration for some and it should be supported by TYPO3 too.
The "issue" as I see it is:
Why try to assign an empty string to an integer field. If the wanted behaviour is that it should be the default values, these should not be set in the fieldArray but be handled by the table definitions.
I don't have a solution for this, just wanted to address the issue.
I'll be glad helping figuring out this issue. But the main idea was to address the issue so we know which direction we should go.
Is for sure related to:
[BUGFIX] Correct handling of empty Backend Layouts
Since the default value of the page properties backend_layout and
backend_layout_next_level is an empty string the value in the select
item is changed from zero to an empty string for consistency.
Additionally the BackendLayoutView will treat an empty string equally
as a zero namely as a non set Backend Layout.
Reviewed-by: Wouter Wolters
Reviewed-by: Stefan Neufeind
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
#1 Updated by Alexander Stehlik about 6 years ago
There seems to be a general problem with Backend Layouts for new pages. When a new page is created the fields in the database
backend_layout_next_level contain empty strings.
BackendLayoutView only checks for values
=== '0' when searching for pages with no explicit Backend Layout. So when if finds an empty string it will assume that there is a Backend Layout set in that page (which of course is not).
I see two solutions for that problem:
- change the default value of
backend_layout_next_levelback to zero
- change the value in the Backend Layout selector also to an empty string instead of zero and adjust the check in
BackendLayoutViewso that it can handle empty strings
Remark on the second solution:
We need either to handle empty strings AND zeros to be backward compatible or we need an updater in the install tool.