[edit]
Description
Fatal error on installing dbee v7.x-3.0.
condition
It happens on specific database install, depending on the allowed max key setting : less than 1000. Especially : MySQL 5.6.32 database
fix
Fixed using the v7.x-3.1 dbee version.
[/edit]
I tried the upgrade procedure (https://www.drupal.org/node/2874047) but it keeps failing on me. I tried the regular update method which keeps throwing errors and encrypt the emails forever. When trying the method of uninstalling DBEE and then installing it again also doesn't work.
root@12a371b7465f:/var/www/html# drush dis -y dbee
The following extensions will be disabled: dbee
Do you really want to continue? (y/n): y
dbee was disabled successfully. [ok]
All users email addresses have been decrypted (concerning 720 of 720 users) [status]
DataBase Email Encryption module disabled. Encryption is disabled now. [status]
root@12a371b7465f:/var/www/html# drush pm-uninstall dbee
The following modules will be uninstalled: dbee
Do you really want to continue? (y/n): y
dbee was successfully uninstalled.
### HERE I UPDATED THE OLD MODULE WITH THE NEW MODULE CODE ###
[ok]
root@12a371b7465f:/var/www/html# drush en -y dbee
The following extensions will be enabled: dbee
Do you really want to continue? (y/n): y
exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes' in [error]
/var/www/html/includes/database/database.inc:2227
Stack trace:
#0 /var/www/html/includes/database/database.inc(2227): PDOStatement->execute(Array)
#1 /var/www/html/includes/database/database.inc(697): DatabaseStatementBase->execute(Array, Array)
#2 /var/www/html/includes/database/mysql/schema.inc(472): DatabaseConnection->query('ALTER TABLE {us...')
#3 /var/www/html/includes/database/database.inc(3076): DatabaseSchema_mysql->changeField('users', 'mail', 'mail', Array, Array)
#4 /var/www/html/profiles/my_project/modules/contrib/dbee/dbee.install(29): db_change_field('users', 'mail', 'mail', Array)
#5 [internal function]: dbee_install()
#6 /var/www/html/includes/module.inc(926): call_user_func_array('dbee_install', Array)
#7 /var/www/html/includes/module.inc(494): module_invoke('dbee', 'install')
#8 /opt/drush-8/vendor/drush/drush/commands/core/drupal/environment_7.inc(143): module_enable(Array)
#9 /opt/drush-8/vendor/drush/drush/commands/pm/pm.drush.inc(1167): drush_module_enable(Array)
#10 [internal function]: drush_pm_enable('dbee')
#11 /opt/drush-8/vendor/drush/drush/includes/command.inc(422): call_user_func_array('drush_pm_enable', Array)
#12 /opt/drush-8/vendor/drush/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#13 [internal function]: drush_command('dbee')
#14 /opt/drush-8/vendor/drush/drush/includes/command.inc(199): call_user_func_array('drush_command', Array)
#15 /opt/drush-8/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#16 /opt/drush-8/vendor/drush/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#17 /opt/drush-8/vendor/drush/drush/drush.php(12): drush_main()
#18 {main}
root@12a371b7465f:/var/www/html#
Looked in the logs and found this:
Warning: Illegal string offset 'label' in encrypt_config_edit_title() (line 644 of /var/www/html/profiles/my_project/modules/contrib/encrypt/encrypt.module).
Notice: Uninitialized string offset: 0 in encrypt_config_edit_title() (line 644 of /var/www/html/profiles/my_project/modules/contrib/encrypt/encrypt.module).
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | batch_update_not_launched_from_drush-2878467-22.patch | 1.46 KB | thedut |
Comments
Comment #2
bramdriesenAdded log errors
Comment #3
thedut commentedHello,
It is not the right procedure to upgragde any drupal module
What you did was :
The right upgrade procedure is :
Or you could (for the dbee module) :
In your case : don't worry, All your users email addresses should be decrypted.
You simply nee to enable the new dbee module from the user Interface (admin/modules).
Comment #4
bramdriesenWhat you mentioned:
Is exactly what I did, I didn't run the update script after changing the module code to the new version. After the crash the module is enabled in the database, but the user table is not altered with the new fields. Therefore the whole Drupal database is messed up and it becomes impossible to disable the module again, or even clear the cache. Everything keeps crashing with the error code
I also tried to update the files and then run the update script, this also doesn't work for me with the same error message if I remember correctly.
Comment #5
bramdriesenComment #6
thedut commentedHum,
Sorry I have made a mistaske, you did the right procedure (the last one).
It seems that changing the {users} mail colomn lenght fails during the install procedure.
Default value is 254, dbee module change it to 500 during the install script.
But it seems you store datas with more than 500 lenght in your {users} mail colomn, do you ?
Comment #7
bramdriesenI highly doubt we have emails that are longer as 254 since this is the current length of the table as well. So updating it to 500 shouldn't be an issue since it's an upscale instead of a downscale.
Comment #8
thedut commentedok, it is not about the mail datas but about the index of the {users} table, especially with inno_db, according to this post.
Solution should be to edit the index parameter of the {users} table.
Comment #9
thedut commentedWe should test it but according to this post, you could update the install script doing something like :
db_drop_index('users', 'mail');Change the colomn length
db_add_index('users', 'mail', array(array('0' => 'mail', '1' => '254')));Comment #10
thedut commentedIn order to make you site working again, you could disable the dbee module (using drush should succeed).
Comment #11
bramdriesenI don't think the issue are the indexes. But the schema alter
According to the manual of MySQL 255 is the max length possible for a varchar. However I'll try the index fix you mentioned.
Comment #12
thedut commentedHere is fix, not tested, changing users table index.
You could test if it solves this issue.
I 'am going to check the second hypothesis.
Comment #13
thedut commentedCould you provide your database type and version ?
It would allow to identifiy drupal install when this issue may happen and help me to reproduce it.
Comment #14
bramdriesenI'm working on a MySQL 5.6.32 database. Going to test the patch in a few minutes.
Comment #15
thedut commentedAbout he second hyppothesis in #11, according to the D7 database documention, allowed varchar length is 64 KB. So length of 500 should be ok. But if the patch in #12 fails we could still test it.
Comment #16
bramdriesenSo I applied the patch and now the module enables fine. However the email addresses are not being encrypted upon enabling of the module. (I disabled, uninstalled, updated the code, applied the patch and then enabled the patched module.)
Comment #17
bramdriesenGoing to the configuration screen of DBEE and clicking the save button with the checkbox "re-encrypt" users encrypted everything. Tested and logging in with emails works without an issue.
Comment #18
bramdriesenIf the emails need to be encrypted upon enabling of the module you'll need to add the same logic as in the "hook_enable" code.
But add this in the install hook. Currently the dbee_update_crypt_all is only triggered by the dbee update hook (7300)
Comment #19
bramdriesenUploaded a new patch where I moved the encrypt code to the install hook and fixed some typos. Since the update hook calls the install hook, there should be no issue with the code move.
Comment #20
bramdriesenComment #21
thedut commentedThank you for your feed back.
This issue is killed !
I have changed the issue title because this issue doesn't only concern updating dbee from v2.5 to v3.0 but may affect new install of the v3.0 dbee module to.
It happens on specific database install, depending on the allowed max key setting.
I don't think we should apply the second patch :
dbee_enabled() is always called after dbee_install(), if the module has been uninstalled ; see order of events.
And the dbee_update_7300() function should have no implication is this issue.
In order make sure about the patch :
could you try one more time to :
Comment #22
bramdriesenI also just came to the same conclusion that the crypt_all function should not be moved. I tested patch #12 and it's working fine. However emails are not being encrypted right after the install, an extra save is needed on the configuration form.
Comment #23
thedut commentedIt seems than on installing the dbee module : the batch operation encrypting all users is not launched by Drush.
According to the Drush documentation, this new patch should fix this last part of the issue.
Could repeat the procedure discribed in #21 with this new patch and tell me if all users are encrypted, without the need on the configuration form ?
Comment #24
thedut commentedComment #25
bramdriesenI confirm the patch is working and all users are correctly encrypted upon enabling the module from Drush. Patch looks good!
Comment #26
thedut commentedGreat, thank you for your work Bram,
I'am going to release the v7.x-3.1 version including this patch. I will credit you in the commit.
Comment #27
thedut commentedComment #28
thedut commentedAll simple tests have passed successfully with #26 patch.
Comment #29
thedut commentedComment #31
thedut commentedComment #32
bramdriesen@thedut Thanks for your effort and quick responses, glad we fixed it so fast! Now we can get rid of AES ;)