{"action":"created","issue":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/9258","repository_url":"https://api.github.com/repos/joomla/joomla-cms","labels_url":"https://api.github.com/repos/joomla/joomla-cms/issues/9258/labels{/name}","comments_url":"https://api.github.com/repos/joomla/joomla-cms/issues/9258/comments","events_url":"https://api.github.com/repos/joomla/joomla-cms/issues/9258/events","html_url":"https://github.com/joomla/joomla-cms/issues/9258","id":137313014,"number":9258,"title":"Unwanted data type changes for table columns on UTF8MB4 conversion","user":{"login":"richard67","id":7413183,"avatar_url":"https://avatars.githubusercontent.com/u/7413183?v=3","gravatar_id":"","url":"https://api.github.com/users/richard67","html_url":"https://github.com/richard67","followers_url":"https://api.github.com/users/richard67/followers","following_url":"https://api.github.com/users/richard67/following{/other_user}","gists_url":"https://api.github.com/users/richard67/gists{/gist_id}","starred_url":"https://api.github.com/users/richard67/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richard67/subscriptions","organizations_url":"https://api.github.com/users/richard67/orgs","repos_url":"https://api.github.com/users/richard67/repos","events_url":"https://api.github.com/users/richard67/events{/privacy}","received_events_url":"https://api.github.com/users/richard67/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/joomla/joomla-cms/labels/3.5.0-blocker","name":"3.5.0-blocker","color":"fbca04"},{"url":"https://api.github.com/repos/joomla/joomla-cms/labels/No%20Code%20Attached%20Yet","name":"No Code Attached Yet","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-02-29T17:09:43Z","updated_at":"2016-02-29T23:04:22Z","closed_at":null,"body":"Related issues #9247 and maybe also #9251\r\n\r\n#9251 could be related because some of the database columns affected by what I describe below belog to the extensions table.\r\n\r\nPriority = urgent because has to be solved before 3.5.0 release.\r\n\r\n#### Steps to reproduce the issue\r\n\r\n1. Update a Joomla! 3.4.8 to 3.5.0 Beta 3.\r\n2. After successful update go to \"Extensions -> Manage -> Database\"\r\n3. You will see a database problem reported that the conversion to \"UTF-8 Multibyte (utf8mb4)\" or \"UTF-8\" (which of these 2 depends on if your database server and client api support utf8mb4 or not) has not been done yet.\r\n4. Click the \"Fix\" button to solve the problem.\r\n\r\n#### Expected result\r\n\r\nAll database problems are solved.\r\n\r\n#### Actual result\r\n\r\nA new problem occurs:\r\n\r\n> Table '#__user_profiles' does not have column 'profile_value' with type 'TEXT'. (From file 3.3.4-2014)\r\n\r\n(replace \"#__\" by your database prefix)\r\n\r\n#### System information (as much as possible)\r\n\r\nNot relevant, happens on all kinds of systems when updating a 3.4.8 (or previous) to 3.5.0 Beta (1 or 2 or 3) with any method (Joomla! Update component or Extensions Installer - Upload and install package).\r\n\r\n#### Additional comments\r\n\r\nThe reason for this behavior is that the statemens\r\n\r\n> ALTER TABLE `#__table_name` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;\r\n\r\nresult on a Joomla! where data is still in utf8 (without mb4) in columns of data type TEXT being changed to MEDIUMTEXT and columns of data type MEDIUMTEXT being changed to LONGTEXT by MySQL, see MySQL bug report [https://bugs.mysql.com/bug.php?id=31291](https://bugs.mysql.com/bug.php?id=31291 \"https://bugs.mysql.com/bug.php?id=31291\") where is clarified that it's not a bug but a feature.\r\n\r\n**This is a general problem affecting many table columns (see list below).**\r\n\r\n**The reason why only the column mentioned above is reported up to now is that this is the only one for which is some update sql with a data type change**.\r\n\r\n**But as soon as in future other columns will be changed in update sqls, those may have the problem, too.**\r\n\r\nMy hopefully complete analysis has given me a long list of Joomla! core table columns being affected (see list below).\r\n\r\nThere is no easy way out without data loss, because the joomla.sql for new installation defines these data types for the columns as before but in the for both kinds of databases with or without utf8mb4 support.\r\n\r\nIf we make these bigger in the joomla.sql and in some update sql file, too, then this results also in bigger data types when being run on a non-utf8mb4 database, where then the max allowed lengths for some column will really be used.\r\n\r\nIf then later the database is migrated to a server supporting utf8mb4, the bigger data types will then be again changed to the next bigger one. And so again the problem occurs and we end up in fure all being of type \"VERY BIG LONG ENDLESS MEGA TEXT\" (if this data type exists in mySQL :smile:\r\n\r\n**One solution could be** to have different joomla.sql for both kinds of databases, we could make the one for utf8mb4 using the bigger types but the one for non-utf8mb4 suign the smaller ones, and handle updating with the utf8(mb4) conversion procedure. This would be one way out but maybe not accepted by PLT and users beause having 2 installation sqls.\r\n\r\n**The other solution is easier but causes data loss:**\r\n\r\nAt the end of the conversion, we change the data types back to what they were. But if somone has used max lenghts for some column's data all the time before, this causes data being truncated.\r\n\r\nIt may differ from column to column which it the best way, e.g. for params column where we know they were by far big enough all the time so we not lose anything when truncating back, we could say we just change back to the old type, as menioned the 2nd way.\r\n\r\nBut for columns like metadata or metadesc this may not be acceptable, so for those we would need the 1st way to handle them.\r\n\r\n**Both of these solutions are not nice to maintain** because when in future new tables or table columns are added or existing ones are changed in some update sql, the statement to handle the unwanted type change on utf8mb4 conversion has to be added to the administrator/components/com_admin/sql/others/mysql/utf8mb4-conversion-02.sql at the end.\r\n\r\n**Or another easy solution could be** that we make the data types bigger in joomla.sql and a new update sql in general and make the installer database model (or was it the database driver?) which replaces \"utf8mb4\" by \"utf8\" in SQL statements before execution be clever enough to change the data types in case of no utf8mb4 support to the smaller one, which is then the one used before 3.5. But this is not easy, we should not just replace \"MEDIUMTEXT\" by \"TEXT\" and \"LONGTEXT\" by \"MEDIUMTEXT\" wherever it occurs in case of no utf8mb4 support, or could we?\r\n\r\nThis replacement should be of course done only on DDL statements and not on insert or update or so, we should implement a way to exclude that. \r\n\r\nIf that would be acceptable it would be not complicated.\r\n\r\nTo make the decision by PLT or experts easier here now the list on affected tables.colums:\r\n\r\n1. Those which automatically changed from TEXT to MEDIUMTEXT at character set conversion\r\n> #__banners.description\r\n#__banners.metakey\r\n#__banners.params\r\n#__banner_clients.extrainfo\r\n#__banner_clients.metakey\r\n#__categories.params\r\n#__contact_details.address\r\n#__contact_details.params\r\n#__contact_details.metakey\r\n#__contact_details.metadesc\r\n#__contact_details.metadata\r\n#__content.images\r\n#__content.urls\r\n#__content.metakey\r\n#__content.metadesc\r\n#__content.metadata\r\n#__content_types.rules\r\n#__content_types.field_mappings\r\n#__extensions.manifest_cache\r\n#__extensions.params\r\n#__extensions.custom_data\r\n#__extensions.system_data\r\n#__finder_filters.data\r\n#__languages.metakey\r\n#__languages.metadesc\r\n#__menu.params\r\n#__messages.message\r\n#__modules.content\r\n#__modules.params\r\n#__newsfeeds.params\r\n#__newsfeeds.metakey\r\n#__newsfeeds.metadesc\r\n#__newsfeeds.metadata\r\n#__newsfeeds.description\r\n#__newsfeeds.images\r\n#__overrider.string\r\n#__tags.params\r\n#__tags.images\r\n#__tags.urls\r\n#__template_styles.params\r\n#__ucm_content.params\r\n#__ucm_content.images\r\n#__ucm_content.urls\r\n#__ucm_content.metakey\r\n#__ucm_content.metadesc\r\n#__updates.description\r\n#__updates.data\r\n#__updates.detailsurl\r\n#__updates.infourl\r\n#__update_sites.location\r\n#__users.params\r\n#__user_notes.body\r\n#__user_profiles.profile_value\r\n\r\n2. Those which automatically changed from MEDIUMTEXT to LONGTEXT at character set conversion\r\n> #__categories.description\r\n#__contact_details.misc\r\n#__content.introtext\r\n#__content.fulltext\r\n#__finder_filters.params\r\n#__session.data\r\n#__tags.description\r\n#__ucm_content.body\r\n#__ucm_history.version_data"},"comment":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/comments/190439568","html_url":"https://github.com/joomla/joomla-cms/issues/9258#issuecomment-190439568","issue_url":"https://api.github.com/repos/joomla/joomla-cms/issues/9258","id":190439568,"user":{"login":"richard67","id":7413183,"avatar_url":"https://avatars.githubusercontent.com/u/7413183?v=3","gravatar_id":"","url":"https://api.github.com/users/richard67","html_url":"https://github.com/richard67","followers_url":"https://api.github.com/users/richard67/followers","following_url":"https://api.github.com/users/richard67/following{/other_user}","gists_url":"https://api.github.com/users/richard67/gists{/gist_id}","starred_url":"https://api.github.com/users/richard67/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richard67/subscriptions","organizations_url":"https://api.github.com/users/richard67/orgs","repos_url":"https://api.github.com/users/richard67/repos","events_url":"https://api.github.com/users/richard67/events{/privacy}","received_events_url":"https://api.github.com/users/richard67/received_events","type":"User","site_admin":false},"created_at":"2016-02-29T23:04:21Z","updated_at":"2016-02-29T23:04:21Z","body":"@andrepereiradasilva No, #9249 is something else.\r\n\r\n#9247 is related to this here but also not the same. While checking for #9247, which is a problem caused by the utf8mb4 changes (but not my stuff), I found what is the reason for these appearing database issues with the profile_value column you also have seen when doing tests for my PRs in past, and I have noticed it is a more severe problem which it first seems to be and so opened this issue here to summarize what the problem is and some ideas on how t solve them."}}