-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed failure on updating database not supporting UTF8MB4 #8472
Conversation
I have tested this item ✅ successfully on 3beecb4 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8472. |
P.S.: When I tested, there were no database problems detected on the database tab after the update had finished, and all 3 new plugins were installed (which also was not the case before and shows that now everything completed). This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8472. |
P.P.S: Just to be on the safer side I just tested if something is broken for MySQL databases which DO support itf8mb4 (MySQL 5.5.46 with collations utf8mb4_general_ci in my case), and all is fine, also there no problems and nothing detected by the database tab. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8472. |
P.P.P.S: Now I am confused: When I did my test before for the MySQL 5.5. database which supports utf8mb4, I did install the update package from a folder. There were no problems shown on the database tab, but now I noticed why: It seems that the collations where not changed for utf8mb4 in the datavase (I checked the alias column of the menu table, which still was utf8_bin). But when I install from the same starting point using the Upload package way, then I get problems shown in the database tab, which then can be fixed with the Fix button, then one last problem is shown, which also can be fixed with the button, and then database tab shows all OK. In the database the collation changes have been applied (menu table, alias column has utf8mb4_bin). So either I made a big mistake when testing or there is a difference between "Upload&Install" and "Install from Folder" methods regarding executing the SQL statements from the SQL files. @roland-d Do you have any idea? Should I alter my test result? or would it be another issue if I am right and there is this difference? This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8472. |
switch ($format) | ||
{ | ||
case 'mysql': | ||
case 'pdomysql': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did pdomysql has this function?
Else i think we should add a $db->getClientVersion that retruns this value.
What is the difference between the server version ($db->getVersion) and mysqli_get_client_info();?
For sure this don't work for pdomysql
if the function mysql_get_client_info(); is not available
For ref this download here contains the current fixes by @roland-d So if you have a install with old mysql pleaase try this. edit: updated the URL. |
@zero-24 @roland-d I just have checked the container and found a mismatch between paths in script.php and the container. In administrator/components/com_admin/script.php line 1593: $fileName = JPATH_ADMINISTRATOR . "/components/com_admin/sql/ut8mb4/$format/3.5.0-2015-07-01.sql"; In file administrator/components/com_installer/models/database.php, line 273: $fileName = JPATH_ADMINISTRATOR . "/components/com_admin/sql/utf8mb4/$serverType/3.5.0-2015-07-01.sql"; And in the zip container you linked above: administrator\components\com_admin\sql\uft8mb4 3 places, 3 variants. I suggest to use the one from administrator/components/com_installer/models/database.php ;-) This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8472. |
|
||
if ($format == 'mysql' && version_compare(JVERSION, '3.5.0', 'lt')) | ||
{ | ||
$fileName = JPATH_ADMINISTRATOR . "/components/com_admin/sql/ut8mb4/$format/3.5.0-2015-07-01.sql"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be utf8mb4 and not ut8mb4 in the path, i.e. the "f" is missing here.
@roland-d Sent a PR to your branch with correction of script.php as mentioned in my comment above. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8472. |
@zero-24 Please pack the container again with the correct folder utf8mb4 as soon as Roland has merged my PR into his repository, see my comment above. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8472. |
tested this item ✅ successfully. No more Message of Failure about UTF8MB4. |
I have tested this item 🔴 unsuccessfully on 3beecb4 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8472. |
Thanks i will check it soon 👍 |
Thanks for testing guys, I have updated the PR with the correct path and removed the pdomysql check because the UTF8MB4 doesn't apply there. |
@richard67 I have done the install from folder test and the upload test and all the results are good. What you are seeing I think is cached data, at least that is what happened to me. I do believe the current fixes are good. |
@roland-d Am still testing, too. I do not think all is cached data. But the current fixes are good anyway. |
@roland-d Just as a reminder: I do both tests for MySQL with and without support for utf8mb4, and with the first one I had the problems. I know this PR here deals with the second one, but it should not break things for the first one, that's why I test both. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8472. |
@richard67 Correct, I have tested both as well. Will re-run the tests again later. Now I am dealing with the differences in the tables after an update compared to a clean install. |
I had also found that 3beecb4 "worked", but only because the typo resulted in it doing nothing. I fix the typo, and I get errors on updating from 3.4.5:
Reviewing again the config that I'm testing with -- a CentOS 6 system with:
I find that support for utf8mb4 was added to mysqlnd here: php/php-src@277c7d4, and the version at that time was mysqlnd 5.0.7-dev. The tags on that commit show that it was first included in php 5.4.0. By the time that php 5.4.0 was released, mysqlnd was bumped up to msyqlnd 5.0.10. I would think that should be considered the first stable version released with utf8mb4 support. The release notes for mysql 5.5.3 confirm that it was the first release supporting utf8mb4. So in my case, I'm using a mysql client that supports utf8mb4, but a server that does not. The Joomla code as patched here is only looking at my client version with This server version check should also be added to As for pdomysql, you should take a look at |
Here the results of my recent 4 tests, with and without support for utf8mb4 and with upload&install package and install from folder. Test 1 - MySQL 5.5.46 (supports utf8mb4) - Upload & Install packageStep 1. Instead of installation finished: Internal Server Error Step 2. Database tab: 4 problems found
Other information:
Step 3. Fix => 1 problem found
Other information:
Step 4. Fix => Database table structure is up to date. Other information:
Step 5. Check plugins: 3 new plugins from 3.5 (editor-button menu, statistics and update notification) NOT installed. Step 6. Check collation in database (menu table, alias column): utf8mb4_bin, lenght 191 => OK. Test 2 - MySQL 5.5.46 (supports utf8mb4) - Install from folderStep 1. Message "Installation of the file was successful." Step 2. Database tab: 1 problem found
Other information:
Step 3. Fix => Database table structure is up to date. Other information:
Step 4. Check plugins: 3 new plugins from 3.5 (editor-button menu, statistics and update notification) installed => OK. Step 5. Check collation in database (menu table, alias column): utf8mb4_bin, lenght 191 => OK. Test 3 - MySQL 5.1.73 (does NOT support utf8mb4) - Upload & Install packageStep 1. Like step 1 of test 1 Step 2. Like step 2 of test 1 Step 3. Fix => Database table structure is up to date, i.e. the 1 problem for table xxxxx_user_profiles which required a second fix in test 1 did not appear here. Other information:
Step 5. Check plugins: 3 new plugins from 3.5 (editor-button menu, statistics and update notification) NOT installed. Test 4 - MySQL 5.1.73 (does NOT support utf8mb4) - Install from folderStep 1. Messages Database query failed (error # 1115): Unknown character set: 'utf8mb4' SQL=-- Convert all tables to UTF-8 Multibyte (utf8mb4) ALTER TABLE Database query failed (error # 1115): Unknown character set: 'utf8mb4' SQL=ALTER TABLE Database query failed (error # 1115): Unknown character set: 'utf8mb4' SQL=ALTER TABLE ... (lots of similar messages for other tables and columns) Database query failed (error # 1115): Unknown character set: 'utf8mb4' SQL=ALTER TABLE Installation of the file was successful. Step 2. Database tab: Database table structure is up to date. Other information:
Step 3. Check plugins: 3 new plugins from 3.5 (editor-button menu, statistics and update notification) installed => OK. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8472. |
@roland-d From my point of view it should be decided by PLT (good that you are a member) before release of 3.5.0 if Joomla! wants to face site owners or admins with data loss and, if so, how far it shall go, apply it like it is with this PR now, i.e. shorten more texts than necessary, or try to optimize that, as @zjw 's comment explains. If you or PLT decide to apply further changes on this PR (or do it with another one), everything has to be tested again, i.e. both new install and update on both kinds of databases for at least database drivers mysqli and pdomysql if not also mysql (without i), so we have 8 to 16 tests to be done, all with comparison of data structures in sql export files afterwards. So or so, if it is taken as it is now or if further optimizations as suggested above by @zjw are applied, the release notes of 3.5.0 have to clearly list all table columns where data losses may appear from my point of view. Releasing this PR as it is now with 3.5.0 and not telling anything about it will very likely cause a lot of complains, because such data losses may not be detected when checking things after upgrade and then a few weeks or months later when they are detected it may be too late to fall back to old data, and forums will be full with support requests. What can be done in order not to further delay the next beta release is to release the beta with status of this PR and then before the final 3.5.0 work on it further and optimize things, because there is no update path from any beta to the next beta. But it has to be finally decided before 3.5.0 which way it goes. I will be offline for the next hours but later I am available for further discussion and testing. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8472. |
I have put the issue before the PLT so we can decide how to move forward. In my opinion we can't cancel this request and leave sites vulnerable just because sites may have aliases beyond the 192 character limit. My idea would be to add a check in the preflight to see if there are any aliases longer than 192 and if so we can cancel the installation with a message informing the user. What that message is going to be is to be determined of course. |
You can't. The way the core update component works, the update is unpacked in full then the upgrade.finalise task is called which triggers a mocked version of a |
@mbabker Thanks for the feedback. |
One way to check and notify could be to release a 3.4.6 which does the check and shows the result in a postinstall message so site admins could react before they upgrade then to 3.5.0, but this would be 1. much additional work maybe and 2. maybe delay the project schedule and 3. only be a theoretical solution since it is not granted every site is going the way from <= 3.4.5 via 3.4.6 to 3.5.0, at least when I see how many questions in the support forum refer to outdated version and even 2.5.x I daubt if this would really help. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8472. |
We could force a step between using the update XML files. There we can target exactly which version of Joomla should an update be shown. So to Joomla <= 3.4.5 only the 3.4.6 would be shown and 3.5.0 to those on 3.4.6. |
Yes, I have the same daubt, but I thought I should mention it here for discussion. |
I have prepared another PR: roland-d#7. It addresses the issues that I brought up earlier. Downsizing of columns to varchar(191) has been eliminated, except for I had mentioned that there was a particular problem with reducing key sizes to 191 characters in cases where those keys were |
{ | ||
$db = JFactory::getDbo(); | ||
|
||
$utf8mb4IsSupported = $this->serverClaimsUtf8mb4Support($db->name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why we don't do $db->hasUTF8mb4Support()
here instead?
@wilsonge: The problem is when updating from 3.4.5 or before. In those cases, |
The script file is not triggered until the filesystem has been updated to 3.5 unless you are updating through the Extension Manager. |
@mbabker: Yes, but the old (3.4.5) database classes have already been loaded before the script is triggered, so I don't think updating the class files makes any difference. The old classes are still the ones in use. |
The <3.5.0 code is ONLY used if you are upgrading via the Extension Manager. Because of the use of AJAX in the update component, the package is extracted in full in several smaller steps then a request to the update component's |
Ah -- that makes sense. I suspect that people performing update tests of this PR are doing so via the extension manager. That method seems like it needs to be supported. |
@roland-d @zjw and others involved into this PR: I have added xml files for using the patched update container (links see above somewhere) to the donwload location, so the container can be used for update via Joomla! Update Component, i.e. it is not necessary to use the Extension Installer anymore for the update tests. To do so, select "Custom URL" as update channel in the Joomla! Update Component's options, and enter "http://test5.richard-fath.de/list_test.xml" as URL: After "Save & Close" you should see then: The update can be started then in the usual way. This method changes the URL in update sites table. To come back to the standard, change the update channel back to what it was before (e.g. Testing). This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8472. |
P.S.: Of course I have tested again with the latest container how I described in my previous comment, and it was successful. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8472. |
@roland-d @zjw and others involved into this PR: I have created new full installation and update containers in case if testing this PR goes on somehow, e.g. with regular Joomla! Update method (i.e. not Extension Installer) or as a base for new containers after any further commits. The containers patched by this PR#s changes are based on latest staging, i.e. they also include the security fixes done with 3.4.6. For update tests with Joomla! Update, use "http://test5.richard-fath.de/list_test.xml" as custom update URL as I described in my comment above. For full installation tests or update tests with the Extension Installer (from folder or upload & install package) use following links: Joomla_3.5.0-beta-Beta-Full_Package_utf8mb4_fix9.zip Joomla_3.5.0-beta-Beta-Update_Package_utf8mb4_fix9.zip Note the changed package name "..._fix9.zip" in case you used "Install from URL" for update tests using the Extension Manager. The links of the old packages "..._fix8.zip" will produce a 410 "gone" now. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8472. |
at least for me updating worked great from joomla 3.4.5 to 3.5 fix 9 on a host where utf8mb4 is not available -- update receive the following error when applying an old database (utf8) to a already patched 3.5.0 fix9 and doing database repairs on an utf8mb4 compatible server afterwards (Fehler # 1071)!: Specified key was too long; max key length is 767 bytes SQL=ALTER TABLE All other alter table commands went fine! |
Just to give an update, I have not forgotten about this but there are a lot more things to be considered/checked. I will be back soon with an update on how we will proceed. |
thx
|
@roland-d Any news? Meanwhile Beta 2 is out and this PR here was claimed to be the show stopper for 3.5, so I have expected this PR here going into the Beta 2. |
Please see the release notes
|
@richard67 The status is that there will be a number of new PRs that will superseed this PR. We have been working behind the scenes to get this issue really cleared up. Once the PRs are ready to be tested, I will link them from here. You are correct, this is a showstopper for 3.5 and will be fixed before the stable is released. |
Closing this based on us merging #9045 as this is now dated. We can come back to this if it doesn't work out in beta 3 |
Problem
Users running a MySQL database that does not support UTF8MB4 will get failures during an update to Joomla 3.5.0 because the queries to update the tables to UTF8MB4 are executed.
Fix
The fix is to modify the SQL queries that are run on databases not supporting UTF8MB4.
Testing
Disclaimer
You may still see database problems on the database tab due to different field definitions. This is not handled in this fix but will be dealt with in another fix.