?
avatar richard67
richard67
29 Feb 2016

Related issues #9247 and maybe also #9251

#9251 could be related because some of the database columns affected by what I describe below belog to the extensions table.

Priority = urgent because has to be solved before 3.5.0 release.

Steps to reproduce the issue

  1. Update a Joomla! 3.4.8 to 3.5.0 Beta 3.
  2. After successful update go to "Extensions -> Manage -> Database"
  3. 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.
  4. Click the "Fix" button to solve the problem.

Expected result

All database problems are solved.

Actual result

A new problem occurs:

Table '#__user_profiles' does not have column 'profile_value' with type 'TEXT'. (From file 3.3.4-2014)

(replace "#__" by your database prefix)

System information (as much as possible)

Not 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).

Additional comments

The reason for this behavior is that the statemens

ALTER TABLE #__table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

result 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 where is clarified that it's not a bug but a feature.

This is a general problem affecting many table columns (see list below).

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.

But as soon as in future other columns will be changed in update sqls, those may have the problem, too.

My hopefully complete analysis has given me a long list of Joomla! core table columns being affected (see list below).

There 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.

If 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.

If 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:

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.

The other solution is easier but causes data loss:

At 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.

It 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.

But for columns like metadata or metadesc this may not be acceptable, so for those we would need the 1st way to handle them.

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.

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?

This 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.

If that would be acceptable it would be not complicated.

To make the decision by PLT or experts easier here now the list on affected tables.colums:

  1. Those which automatically changed from TEXT to MEDIUMTEXT at character set conversion

    #__banners.description
    #__banners.metakey
    #__banners.params
    #__banner_clients.extrainfo
    #__banner_clients.metakey
    #__categories.params
    #__contact_details.address
    #__contact_details.params
    #__contact_details.metakey
    #__contact_details.metadesc
    #__contact_details.metadata
    #__content.images
    #__content.urls
    #__content.metakey
    #__content.metadesc
    #__content.metadata
    #__content_types.rules
    #__content_types.field_mappings
    #__extensions.manifest_cache
    #__extensions.params
    #__extensions.custom_data
    #__extensions.system_data
    #__finder_filters.data
    #__languages.metakey
    #__languages.metadesc
    #__menu.params
    #__messages.message
    #__modules.content
    #__modules.params
    #__newsfeeds.params
    #__newsfeeds.metakey
    #__newsfeeds.metadesc
    #__newsfeeds.metadata
    #__newsfeeds.description
    #__newsfeeds.images
    #__overrider.string
    #__tags.params
    #__tags.images
    #__tags.urls
    #__template_styles.params
    #__ucm_content.params
    #__ucm_content.images
    #__ucm_content.urls
    #__ucm_content.metakey
    #__ucm_content.metadesc
    #__updates.description
    #__updates.data
    #__updates.detailsurl
    #__updates.infourl
    #__update_sites.location
    #__users.params
    #__user_notes.body
    #__user_profiles.profile_value

  2. Those which automatically changed from MEDIUMTEXT to LONGTEXT at character set conversion

    #__categories.description
    #__contact_details.misc
    #__content.introtext
    #__content.fulltext
    #__finder_filters.params
    #__session.data
    #__tags.description
    #__ucm_content.body
    #__ucm_history.version_data

avatar richard67 richard67 - open - 29 Feb 2016
avatar richard67 richard67 - change - 29 Feb 2016
The description was changed
avatar richard67 richard67 - change - 29 Feb 2016
The description was changed
avatar richard67 richard67 - change - 29 Feb 2016
The description was changed
avatar richard67
richard67 - comment - 29 Feb 2016

I can make a PR to solve that, but I not want to decide alone which way to go, so some maintainer(s) or PTL member(s) please advice.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9258.

avatar richard67 richard67 - change - 29 Feb 2016
The description was changed
avatar richard67 richard67 - change - 29 Feb 2016
The description was changed
avatar richard67 richard67 - change - 29 Feb 2016
The description was changed
avatar stellainformatica
stellainformatica - comment - 29 Feb 2016

Hi richard67,
also on a fresh install of a Joomla 3.5 beta3 in Extensions > Manage > Database I see this error:

Warning: Database is not up to date!

Table 'joomla35beta3.#__utf8_conversion' doesn't exist SQL=SELECT converted FROM #__utf8_conversion WHERE converted = 2;

2 Database Problems Found

Table 'kdt5a_utf8_conversion' does not exist. (From file 3.5.0-2016-02-26.sql.)
The Joomla! Core database tables have not been converted yet to UTF-8 Multibyte (utf8mb4).


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9258.

avatar richard67
richard67 - comment - 29 Feb 2016

@stellainformatica Ahhh I see. Well, using the "Fix" button should fix that for you, but of course it should not happen after a new install. I simply have forgotten to add creation of this new utf8_conversion to the installation/sql/mysql/joomla.sql (shame, blush).

Thank you very much for informing me about that. I will open a pull request (PR) for that.

Could you let me know if the fix button fixes that for you so the description in my PR will be precise? Thanks in advance.

avatar stellainformatica
stellainformatica - comment - 29 Feb 2016

Yes the Fix button fixes the issue:

Database table structure is up to date.

Thanks to you ;)

avatar richard67
richard67 - comment - 29 Feb 2016

@stellainformatica New pull request for the issue you have found is PR #9260 . Please wait a bit with testing until travis check is OK.

avatar wilsonge wilsonge - change - 29 Feb 2016
Labels Added: ?
avatar richard67
richard67 - comment - 29 Feb 2016

@stellainformatica The PR #9260 solving the issue with new installation you have reported here has just been merged, i.e. the problem is solved in current staging code. Thank you for reporting. Of course the problem where this issue here refers to still remains.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9258.

avatar andrepereiradasilva
andrepereiradasilva - comment - 29 Feb 2016

@richard67 #9249 is the same problem?

avatar richard67
richard67 - comment - 29 Feb 2016

@andrepereiradasilva No, #9249 is something else.

#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.

avatar wilsonge wilsonge - reference | 24f6fdf - 1 Mar 16
avatar wilsonge
wilsonge - comment - 1 Mar 2016

OK Me and Eli devised a horribly hacky fix for this in 24f6fdf

avatar wilsonge
wilsonge - comment - 1 Mar 2016

Can we give this a test please?

avatar andrepereiradasilva
andrepereiradasilva - comment - 1 Mar 2016

test instructions?

avatar wilsonge
wilsonge - comment - 1 Mar 2016

This should fix the profile fields issue described in #9247

avatar andrepereiradasilva
andrepereiradasilva - comment - 1 Mar 2016

yes but you guys have a url or zip to update to?

avatar richard67
richard67 - comment - 1 Mar 2016

You can test it with a new install of 3.5.0 Beta 3, too:

Edit file "administrator/components/com_admin/sql/updates/mysql/3.5.0-2016-02-26.sql" and add a create table statement for a new table, e.g. "#__gagatable" at the end of the file.

Then go to Extensions -> Manage -> Database. The missing table should be reported there.

Click Fix -> Now this "Table '#__user_profiles' does not have column 'profile_value' with type 'TEXT'. (From file 3.3.4-2014)" is shown as database problem, which was not shown before.

Now install new again, apply this patch and do the same steps. Result: No 2nd database problem "Table '#__user_profiles' does not have column 'profile_value' with type 'TEXT'. (From file 3.3.4-2014)" is shown.

avatar richard67
richard67 - comment - 1 Mar 2016

Zip for test with update will take a while, I'll post here the link when I have it finished.

avatar brianteeman brianteeman - change - 1 Mar 2016
Category Installation SQL Updating
avatar brianteeman brianteeman - change - 1 Mar 2016
Labels
avatar richard67
richard67 - comment - 1 Mar 2016

@wilsonge Your hack does not work here. Reason could wrong quoting of column name and string literals, but am not sure. Am testing here and let you know the results.

@andrepereiradasilva Better wait until fixed before testing.

avatar richard67
richard67 - comment - 1 Mar 2016

@wilsonge I can tell you why your hack cannot work: The type value you compare with your string literals are already dbQuoted (by this fixQuote private function) and so not compare with the literals. Am just fixing this heree and test.

avatar richard67 richard67 - reference | 8bc098b - 1 Mar 16
avatar wilsonge
wilsonge - comment - 1 Mar 2016

ah. bugger.

avatar richard67
richard67 - comment - 1 Mar 2016

I am just preparing a new branch in my repository with corrections of several bugs in this. Shall I make a (public) PR to staging then? Or let you know where to find and you check and we go the inofficial way?

avatar wilsonge
wilsonge - comment - 1 Mar 2016

Preferably to the repo - but don't worry about writing harry potter. just a couple of lines on what your doing. For testing instructions just refer to #9247

avatar richard67
richard67 - comment - 1 Mar 2016

Oky doky ... will come in a minute or 2

avatar richard67
richard67 - comment - 1 Mar 2016

@wilsonge @andrepereiradasilva New PR #9267 to fix George's hack (did not work). See there how to test and links to patched update zip package and custom update URL.

avatar richard67
richard67 - comment - 1 Mar 2016

@wilsonge Question: Shall I close this one here because the issue with database problems being shown where they should not be on databases supporting utf8mb4 is solved with the just merged #9267 ? Or shall I leave it open because discussion is still ongoing for the more general aspects of the problem described here?


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9258.

avatar wilsonge wilsonge - change - 1 Mar 2016
Labels Removed: ?
avatar wilsonge
wilsonge - comment - 1 Mar 2016

I'm happy with how we are for 3.5 (so I'm removing the 3.5 blocker tag). If you personally want to look into it further for a future version I'd definitely be open to that (because I'm painfully aware what we are doing is a massive hack - but it honestly might be easier to write the schema checker from scratch.....)

avatar richard67
richard67 - comment - 1 Mar 2016

No, If you are ok with it I will close this here. We still have it as reference to read if necessary.

avatar wilsonge
wilsonge - comment - 1 Mar 2016

OK. Closed it is. I think rebuilding the schema checker is something me, Nic and Eli will talk about at JAB (which you're more than welcome to sit in on if you are going to be there)

avatar wilsonge wilsonge - change - 1 Mar 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-03-01 20:42:30
Closed_By wilsonge
avatar wilsonge wilsonge - close - 1 Mar 2016

Add a Comment

Login with GitHub to post a comment